Re: [Rails] Calling function from html.erb
On 3 March 2014 19:57, Alfredo Barrero abarrer...@gmail.com wrote: Good night everyone, My name is Alfredo Barrero and I'm getting started with RoR. I have been learning with Agile Web Development. Now I'm trying to do my own web application. I have a problem and I don't know what I'm doing wrong, could you please give me a hand?. This is what I'm trying to do: %= button_to 'Add Photo' , home_add_path(user_id: user) % I have this line on routes.rb = get '/home/add' = 'photos#add', but the browser gives me this error undefined local variable or method `user' for ##Class:0x007fe075485dc0:0x007fe0738e8d38 The question is, how can I call a method from a html.erb?. Your book should tell you how to setup data in a controller for access from a view, using @variables. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtcO8P1JBumJ6mP7yhPHS7cytHB9h3-h2WR0ykHV3ZKug%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] What are the best strategies/practices for Rails upgradation from 2.3.11 to 4.0.0?
On 4 March 2014 05:09, Raju Ay r...@railsfactory.org wrote: I would like to upgrade one of my application from rails -2.3.11 to 4.0.0. Before going to do anything, I just need plan for it and my application not that much of big size but got some 6/7 plugins and 5/6 gems. Existed: Ruby 1.8.7 + Rails 2.3.11 Expected : Ruby 2.0.0 + Rails 4.0.0 For this, I have plan as in two ways like below, 1).Multi-step process : First need to upgrade app from rails 2.* to 3.* and then do upgrade from rails 3.* to 4.0.0 2).Create new application from rails - 4.0.0 and rebuild old application all features as we have already css, layouts... I hope both strategies will take same time. Any how, I need some inputs from you all. So please share your thoughts/comments. Step zero is to make sure that you have full test coverage so that you can be confident the app continues to work correctly. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvQnCVrE2wyswyR_CBwgjQ0qh-3SnXfo5NP6nAxkLoN6w%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Dependency drop down list
Hello, I am trying load a drop down list based on selection from first drop down list. Based on first drop down list selection, I am able to fetch data for second drop down list but I am not able to refresh second dropdown list contents. How Can I refresh second drop list on selection of first drop down list, I have values for drop down list in an array. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c8b27d303387f4daad01b649bc44%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] navigation list order by
Hello Everybody I have a navigation that draws data from a category table, I would like to display the navigation by category ID order, this is the code I have so far %= link_to category.title, category_path(category) % in the view not sure where to go next to get order by category id Steven -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/47a200f9-f320-47cc-9a4e-97fb04d443d6%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] multiple files upload
Hi, I am newbie to Ruby on Rails.I am trying to develop multiple files upload sample app using any plugin with Rails 4.0 version, but I haven't find much information on that over the web. So,Please suggest me or provide any info to develop it. Thanks, Subbu -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e2e947ab76977df6fa78bbb2de43961%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: Is it possible to backup Solr
Thanks :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/88a3ea59ea097803d566be88ea1ed9f8%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: navigation list order by
Not sure from your question, you seem to be asking How do I sort the Categories index? but you've provided a link_to that deals with a single Category. Typically, you'ld order your Categories in the controller index method and the ordered list would be available in the index.html.erb view as @categories. You could then step through this list in your view with @catagories.each do |category|. If that's what you've done then category (in your link_to) should be the id of a single category. At any rate, you would really help yourself by getting familiar with the Rails Guides at http:guides.rubyonrails.org. On Tuesday, March 4, 2014 5:25:54 AM UTC-5, Steven Cahill wrote: Hello Everybody I have a navigation that draws data from a category table, I would like to display the navigation by category ID order, this is the code I have so far %= link_to category.title, category_path(category) % in the view not sure where to go next to get order by category id Steven -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f8397571-a06a-4a16-92c1-570b200cadd5%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] What are the best strategies/practices for Rails upgradation from 2.3.11 to 4.0.0?
Step zero point one is to review your 6/7 plugins and 5/6 gems and ensure they've been moved forward to your final target. On Tuesday, March 4, 2014 4:05:51 AM UTC-5, Colin Law wrote: On 4 March 2014 05:09, Raju Ay ra...@railsfactory.org javascript: wrote: I would like to upgrade one of my application from rails -2.3.11 to 4.0.0. Before going to do anything, I just need plan for it and my application not that much of big size but got some 6/7 plugins and 5/6 gems. Existed: Ruby 1.8.7 + Rails 2.3.11 Expected : Ruby 2.0.0 + Rails 4.0.0 For this, I have plan as in two ways like below, 1).Multi-step process : First need to upgrade app from rails 2.* to 3.* and then do upgrade from rails 3.* to 4.0.0 2).Create new application from rails - 4.0.0 and rebuild old application all features as we have already css, layouts... I hope both strategies will take same time. Any how, I need some inputs from you all. So please share your thoughts/comments. Step zero is to make sure that you have full test coverage so that you can be confident the app continues to work correctly. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a894903b-06bf-493d-8e94-fac2a8f5e388%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Testing strong parameters
Hi guys, Has anyone figured out how to test strong parameters? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a5f958b3-17cb-4998-a2d7-a536b732dfc7%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] multiple files upload
The simplest multiple file upload I have seen is using the browser-native method of applying multiple: true to the file field. (This does exclude older versions of IE, but they will simply be able to upload a single file.) To make this work, the form must be on the parent of the association -- so if you have a Catalog that has_many Products, you would create a nested form on the Catalog, with accepts_nested_attributes_for :products set on that model, and the Product would have an attachment of some sort (Paperclip, CarrierWave, Dragonfly) to accept the file. The other key to this trick is the naming of the field. Here's a copy-paste from such a field in a live application: %= file_field_tag('project_assets_attributes_blob', multiple: true, name: project[assets_attributes][][blob]) % (Yes, I did learn why you don't name your model Asset -- please don't copy this exactly.) As far as I can determine, there's no good way to get the Rails form view helpers to write out this name directly, so specifying it like this makes it unambiguous what you are up to. The only other thing you need to do is properly educate your users that they can Shift-click to select a contiguous group of files, or Command/Control click to select a discontiguous group. Walter On Mar 4, 2014, at 6:43 AM, Subbu Edimbeta wrote: Hi, I am newbie to Ruby on Rails.I am trying to develop multiple files upload sample app using any plugin with Rails 4.0 version, but I haven't find much information on that over the web. So,Please suggest me or provide any info to develop it. Thanks, Subbu -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e2e947ab76977df6fa78bbb2de43961%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/83D73DBA-51AD-45B0-B9FF-9C0A52145513%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Calling function from html.erb
Put your code on github. It could be a good oportunity to you train git, and for us, is an easier way to know what the context of your problem... First, I recommend to read that: http://guides.rubyonrails.org/routing.html Second... try plan better your routes. It's not related with your currently problem at all... but do you agree that it's a bit odd to add a home for a photo? Does it not look natural to add a photo to an user? so... looks more natural a route like :user/photo/add translated to user_photo_add(@user) On Tue, Mar 4, 2014 at 6:04 AM, Colin Law clan...@gmail.com wrote: On 3 March 2014 19:57, Alfredo Barrero abarrer...@gmail.com wrote: Good night everyone, My name is Alfredo Barrero and I'm getting started with RoR. I have been learning with Agile Web Development. Now I'm trying to do my own web application. I have a problem and I don't know what I'm doing wrong, could you please give me a hand?. This is what I'm trying to do: %= button_to 'Add Photo' , home_add_path(user_id: user) % I have this line on routes.rb = get '/home/add' = 'photos#add', but the browser gives me this error undefined local variable or method `user' for ##Class:0x007fe075485dc0:0x007fe0738e8d38 The question is, how can I call a method from a html.erb?. Your book should tell you how to setup data in a controller for access from a view, using @variables. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtcO8P1JBumJ6mP7yhPHS7cytHB9h3-h2WR0ykHV3ZKug%40mail.gmail.com . For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANPOtXsDY4obBxjTwviDiz9r81gPb02K1vCrV%3D9rF0cdRYDpqQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: navigation list order by
Thanks Rick on the actual categories page the categories are listed in category_id order correctly, I have the following code in my controller # GET /categories # GET /categories.json def index @categories = Category.order('id asc') end The only problem is the navigation list that I have put into the application layout page seems to have a mind of its own, here is the code for li class=link% Category.all.each do |category| % %= link_to category.name, category_path(category), :order = ('id desc') % % end %/li /ul /div /nav it just displays the list in a random order. On Tuesday, March 4, 2014 10:25:54 AM UTC, Steven Cahill wrote: Hello Everybody I have a navigation that draws data from a category table, I would like to display the navigation by category ID order, this is the code I have so far %= link_to category.title, category_path(category) % in the view not sure where to go next to get order by category id Steven -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5dce3073-c36a-4b12-a0d2-4a1e2b155835%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Rails controller problems
On Mon, Mar 3, 2014 at 4:01 PM, Brandon wongw...@gmail.com wrote: This is what my User/Create looks like after rethinking my controller. Does it need more work to make it slimmer? I've seen (and even made) much worse, but this can be slimmed down fairly easily. The sign_in and that big if-statement, have nothing to do with what screen to show next, data to show there other than what's already in some already-used model, or other such things that properly belong in the controller. So, they can be extracted and put into the User model, though you may need to pass in the current_order_id and current_follow_id. You'd wind up with something like: def create user.updating_password = true if user.save user.process_initial_session(current_order_id, current_follow_id) redirect_back_or root_url, flash = { :success = 'Welcome!' } else render 'new' end end where user.process_initial_session (or whatever you choose to call it; could be welcome, set_up_stuff, link_to_order_or_followers, whatever, depending what else you may want to put in it) encapsulates all that extracted stuff. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us); FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014; creator of Pull Request Roulette, at PullRequestRoulette.com. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQiimofZaZKBgzDgUVJM%2B3n53OzHE%3DPa3yyGJbZdCGTDkPw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Testing strong parameters
On Tue, Mar 4, 2014 at 8:49 AM, bertly_the_coder much...@gmail.com wrote: Has anyone figured out how to test strong parameters? You mean test the concept itself, or test that your usage of it does what you intend? I haven't done so, but offhand, I would guess you could do that by testing a few requests with good or bad parameter sets, and seeing whether Rails gritches about them or not. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us); FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014; creator of Pull Request Roulette, at PullRequestRoulette.com. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQih-OpgNgnvPwXpC4aJ_%2BKWs6%3DaVdyDZx3%2B7_8BuXbhaeg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Re: navigation list order by
Hi Steve: Try the following: % Category.order(id DESC).each do |category| % rather than Category.all ... See http://guides.rubyonrails.org/active_record_querying.html#ordering Don Ziesig On 03/04/2014 12:04 PM, Steven Cahill wrote: Thanks Rick on the actual categories page the categories are listed in category_id order correctly, I have the following code in my controller # GET /categories # GET /categories.json def index @categories = Category.order('id asc') end The only problem is the navigation list that I have put into the application layout page seems to have a mind of its own, here is the code for li class=link% Category.all.each do |category| % %= link_to category.name, category_path(category), :order = ('id desc') % % end %/li /ul /div /nav it just displays the list in a random order. On Tuesday, March 4, 2014 10:25:54 AM UTC, Steven Cahill wrote: Hello Everybody I have a navigation that draws data from a category table, I would like to display the navigation by category ID order, this is the code I have so far %= link_to category.title, category_path(category) % in the view not sure where to go next to get order by category id Steven -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5dce3073-c36a-4b12-a0d2-4a1e2b155835%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/53160A05.9040804%40ziesig.org. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] navigation list order by
On Mar 4, 2014, at 10:04 AM, Steven Cahill ste...@yorkshirebroadband.com wrote: def index @categories = Category.order('id asc') end The only problem is the navigation list that I have put into the application layout page seems to have a mind of its own, here is the code for So why are you using Category.all instead of @categories? -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/C086EC4D-F002-4589-AB5A-258A0C72D296%40elevated-dev.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Mysql2::Error: Lost connection to MySQL server during query: SELECT
I keep getting this type of error, and have researched this for weeks on the internet. tried every suggestion and it still persists.. An ActiveRecord::StatementInvalid occurred in customer#go_to_consultation: Mysql2::Error: Lost connection to MySQL server during query: SELECT `users`.* FROM `users` WHERE `users`.`id` = x LIMIT 1 mysql2 (0.2.18) lib/active_record/connection_adapters/mysql2_adapter.rb:265:in `query' nginx version: nginx/1.2.4 ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] Phusion Passenger version 3.0.18 rails (3.0.20) mysql2 (0.2.18) activerecord (3.0.20) activerecord-import (0.2.11) activerecord-mysql2-adapter (0.0.3) Ubuntu 12.04 (precise) other info: * PASSENGER_APP_SPAWNER_IDLE_TIME : -1 * PASSENGER_APP_TYPE: rack * PASSENGER_CONNECT_PASSWORD: [FILTERED] * PASSENGER_DEBUGGER: false * PASSENGER_ENVIRONMENT : production * PASSENGER_FRAMEWORK_SPAWNER_IDLE_TIME : -1 * PASSENGER_FRIENDLY_ERROR_PAGES: true * PASSENGER_GROUP : * PASSENGER_MAX_REQUESTS: 0 * PASSENGER_MIN_INSTANCES : 2 * PASSENGER_SHOW_VERSION_IN_HEADER : true * PASSENGER_SPAWN_METHOD: smart-lv2 * PASSENGER_USER: * PASSENGER_USE_GLOBAL_QUEUE: true mysql2 (0.2.18) lib/active_record/connection_adapters/mysql2_adapter.rb:265:in `query' mysql2 (0.2.18) lib/active_record/connection_adapters/mysql2_adapter.rb:265:in `execute' activerecord (3.0.20) lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log_without_newrelic_instrumentation' activesupport (3.0.20) lib/active_support/notifications/instrumenter.rb:21:in `instrument' activerecord (3.0.20) lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log_without_newrelic_instrumentation' newrelic_rpm (3.7.2.192) lib/new_relic/agent/instrumentation/active_record.rb:46:in `log' newrelic_rpm (3.7.2.192) lib/new_relic/agent/method_tracer.rb:281:in `trace_execution_scoped' newrelic_rpm (3.7.2.192) lib/new_relic/agent/instrumentation/active_record.rb:43:in `log' mysql2 (0.2.18) lib/active_record/connection_adapters/mysql2_adapter.rb:265:in `execute' mysql2 (0.2.18) lib/active_record/connection_adapters/mysql2_adapter.rb:586:in `select' activerecord (3.0.20) lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all' activerecord (3.0.20) lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `select_all' activerecord (3.0.20) lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `cache_sql' activerecord (3.0.20) lib/active_record/connection_adapters/abstract/query_cache.rb:54:in `select_all' activerecord (3.0.20) lib/active_record/base.rb:473:in `find_by_sql_without_trace_ActiveRecord_self_name_find_by_sql' newrelic_rpm (3.7.2.192) lib/new_relic/agent/method_tracer.rb:549:in `find_by_sql' newrelic_rpm (3.7.2.192) lib/new_relic/agent/method_tracer.rb:281:in `trace_execution_scoped' newrelic_rpm (3.7.2.192) lib/new_relic/agent/method_tracer.rb:544:in `find_by_sql' activerecord (3.0.20) lib/active_record/relation.rb:64:in `to_a' activerecord (3.0.20) lib/active_record/relation/finder_methods.rb:343:in `find_first' activerecord (3.0.20) lib/active_record/relation/finder_methods.rb:122:in `first' activerecord (3.0.20) lib/active_record/relation/finder_methods.rb:244:in `send' activerecord (3.0.20) lib/active_record/relation/finder_methods.rb:244:in `find_by_attributes' activerecord (3.0.20) lib/active_record/base.rb:997:in `send' activerecord (3.0.20) lib/active_record/base.rb:997:in `method_missing' lib/authenticated_system.rb:11:in `current_user' app/controllers/application_controller.rb:16:in `load_org_hash' activesupport (3.0.20) lib/active_support/callbacks.rb:447:in `_run__1783524324__process_action__741958110__callbacks' activesupport (3.0.20) lib/active_support/callbacks.rb:410:in `send' activesupport (3.0.20) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks' activesupport (3.0.20) lib/active_support/callbacks.rb:94:in `send' activesupport (3.0.20) lib/active_support/callbacks.rb:94:in `run_callbacks' actionpack (3.0.20) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (3.0.20) lib/action_controller/metal/rescue.rb:17:in `process_action' actionpack (3.0.20) lib/action_controller/metal/instrumentation.rb:30:in `process_action' activesupport (3.0.20) lib/active_support/notifications.rb:52:in `instrument' activesupport (3.0.20) lib/active_support/notifications/instrumenter.rb:21:in `instrument' activesupport (3.0.20) lib/active_support/notifications.rb:52:in `instrument' actionpack (3.0.20) lib/action_controller/metal/instrumentation.rb:29:in
Re: [Rails] Testing strong parameters
They all pass. That's the problem. Mass-assignment doesn't seem to get caught by the testing environment. On Tuesday, March 4, 2014 8:13:03 PM UTC+3, Dave Aronson wrote: On Tue, Mar 4, 2014 at 8:49 AM, bertly_the_coder muc...@gmail.comjavascript: wrote: Has anyone figured out how to test strong parameters? You mean test the concept itself, or test that your usage of it does what you intend? I haven't done so, but offhand, I would guess you could do that by testing a few requests with good or bad parameter sets, and seeing whether Rails gritches about them or not. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us); FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014; creator of Pull Request Roulette, at PullRequestRoulette.com. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a61b3550-1cff-4e15-8295-766d0219bb83%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Group_by for inbox
How an I make the code below only show no new messages once rather than multiple times when there are multiple tickets? %tbody - @users_tickets.each do |t| - unless t.ticket_replies.empty? %tr %td= t.business.name %td= link_to #{t.contact.title}+(+ #{t.ticket_replies.count}+), inbox_path(t) %td = h distance_of_time_in_words_to_now(t.created_at,include_seconds = true) ago - else %b No new messages. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/87a1b99e1d3fec07cbcd038132a6f742%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Testing strong parameters
On Tue, Mar 4, 2014 at 1:13 PM, bertly_the_coder much...@gmail.com wrote: They all pass. That's the problem. Mass-assignment doesn't seem to get caught by the testing environment. Ah, yes, that is odd. Maybe you could check out the tests from that part of Rails, or of the strong_parameters gem, and see how they do it. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us); FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014; creator of Pull Request Roulette, at PullRequestRoulette.com. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQihUm7BQo1D8nT2ddULRpgmpd7wpu-%2BpW4yq_CYz2TTwQA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Making sure the Admin of a website is not deleted
Hello, I am a second year undergrad designing a ruby on rail program for wedding. I am struggling so much with lots of code but one main thing which I don't understand how to do is to make sure that if the administrator has the rights to delete any registered users, then they don't delete their own account in the process, as is currently the case. Please can someone help me? I know it is a code within user controller.rb which has def destroy but I don't know how to go about doing that. Thank you Zainab Mohamed -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e1541e64d742fbc8d53eaf8aa1e547c%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Making sure the Admin of a website is not deleted
You can use a before_action filter in the controller to check both the current user's permissions and the user he is about to delete. And if it is another admin user or himself, then redirect them to another page with a flash error message. More details at the filter link below http://guides.rubyonrails.org/action_controller_overview.html Thanks, Ganesh On Wed, Mar 5, 2014 at 12:37 AM, Zainab Mohamed li...@ruby-forum.comwrote: Hello, I am a second year undergrad designing a ruby on rail program for wedding. I am struggling so much with lots of code but one main thing which I don't understand how to do is to make sure that if the administrator has the rights to delete any registered users, then they don't delete their own account in the process, as is currently the case. Please can someone help me? I know it is a code within user controller.rb which has def destroy but I don't know how to go about doing that. Thank you Zainab Mohamed -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5e1541e64d742fbc8d53eaf8aa1e547c%40ruby-forum.com . For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALFmRoHTgi5KgJnuCCHLnxvqn%3DDxSToc2_WGVUyi4z9xmTTOCQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: Making sure the Admin of a website is not deleted
Ganesh Ranganathan wrote in post #1138798: You can use a before_action filter in the controller to check both the current user's permissions and the user he is about to delete. And if it is another admin user or himself, then redirect them to another page with a flash error message. More details at the filter link below http://guides.rubyonrails.org/action_controller_overview.html Thanks, Ganesh Hi, Thank you for your reply. I only have one admin on the website as shown below (code taken from seeds.rb). User.create(:name = weds4u, :password = w, :password_confirmation = w, :role = 'admin') User.create(:name = Afsheen, :password = a, :password_confirmation = a, :role = '') I tried the following IF statement from another website but that doesn't seem to work. Could you suggest some correction to the below code or do I need to change where I am putting the code in the first place? def destroy @user = User.find(params[:id]) if not user.role = 'admin' @user.destroy else respond_to do |format| format.html { redirect_to users_path, notice: #{@user.name} is an admin. You do not have permission to delete this user } format.json { head :no_content } end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/98274dcda77f83469cc63d75dd8c0e8d%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: Making sure the Admin of a website is not deleted
Hi, Thank you for your reply. I only have one admin on the website as shown below (code taken from seeds.rb). User.create(:name = weds4u, :password = w, :password_confirmation = w, :role = 'admin') User.create(:name = Afsheen, :password = a, :password_confirmation = a, :role = '') I tried the following IF statement from another website but that doesn't seem to work. Could you suggest some correction to the below code or do I need to change where I am putting the code in the first place? def destroy @user = User.find(params[:id]) if not user.role = 'admin' @user.destroy else respond_to do |format| format.html { redirect_to users_path, notice: #{@user.name} is an admin. You do not have permission to delete this user } format.json { head :no_content } end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/10e7e5bfcb5496400ee95fc1364b50a6%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: Making sure the Admin of a website is not deleted
On Tuesday, March 4, 2014 2:54:38 PM UTC-5, Ruby-Forum.com User wrote: Hi, Thank you for your reply. I only have one admin on the website as shown below (code taken from seeds.rb). User.create(:name = weds4u, :password = w, :password_confirmation = w, :role = 'admin') User.create(:name = Afsheen, :password = a, :password_confirmation = a, :role = '') I tried the following IF statement from another website but that doesn't seem to work. Could you suggest some correction to the below code or do I need to change where I am putting the code in the first place? def destroy @user = User.find(params[:id]) if not user.role = 'admin' @user.destroy else respond_to do |format| format.html { redirect_to users_path, notice: #{@user.name} is an admin. You do not have permission to delete this user } format.json { head :no_content } end end -- Posted via http://www.ruby-forum.com/. IMO, this isn't good code. I recommend you look at railstutorial.org which has an online book. Chapters 6-9 give a very good tutorial on building user login functionality, how to insure only admins can delete users, and how to insure an admin can't delete themselves. As Ganesh posted above, generally before_actions are used in the controller instead of the language you have above to insure only admins can delete users. I believe this tutorial is good because it builds authentication from the ground up (roll your own) and you learn the concepts. In practice, I don't usually do that because there are gems that are easier to use such as devise. Good Luck. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2f3eab85-7788-4a8c-b91d-df6e249df511%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Testing strong parameters
LOL! Thx Dave. Anyone else figured/figuring this out or found some documentation about it? On Tuesday, March 4, 2014 10:02:50 PM UTC+3, Dave Aronson wrote: On Tue, Mar 4, 2014 at 1:13 PM, bertly_the_coder muc...@gmail.comjavascript: wrote: They all pass. That's the problem. Mass-assignment doesn't seem to get caught by the testing environment. Ah, yes, that is odd. Maybe you could check out the tests from that part of Rails, or of the strong_parameters gem, and see how they do it. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us); FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014; creator of Pull Request Roulette, at PullRequestRoulette.com. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/26c2181f-9cf3-4608-a002-d923746d591c%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: navigation list order by
On Tuesday, March 4, 2014 12:04:46 PM UTC-5, Steven Cahill wrote: Thanks Rick on the actual categories page the categories are listed in category_id order correctly, I have the following code in my controller # GET /categories # GET /categories.json def index @categories = Category.order('id asc') end The only problem is the navigation list that I have put into the application layout page seems to have a mind of its own, here is the code for If, by application layout page you mean app/views/catagories/index.html.erb, use @categories.each *not*Category.all.each. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/97d02951-07b2-4e8c-b538-3fbfe86c7ffa%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] find_by_sql query running incredibly slow
Initially, I was using this query: report_ids = [] if units.size 0 units.map(:id).uniq.each do |id| report_id = Report.select(:id).where(unit_id: id).order(time desc).first unless report_id.nil? report_ids report_id end end end reports = Report.where(id: report_ids).order(longitude desc) It looks sloppy, and it took around 7 or 8 seconds to load all the data. So I wanted to create a cleaner, quicker query, so I tried this: reports = Report.find_by_sql([SELECT DISTINCT ON (unit_id) r.* FROM reports r WHERE r.unit_id IN (?) ORDER BY unit_id, time DESC, units.map(:id)]) But this is running incredibly slow. In fact, after 15 minutes, I just cancelled the process. Any idea why the second query is taking markedly longer than the first? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cd947975-2605-432d-bdfb-6e25be66e806%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] Testing strong parameters
Use permitters instead. Easily testable. On Mar 5, 2014 3:26 AM, bertly_the_coder much...@gmail.com wrote: LOL! Thx Dave. Anyone else figured/figuring this out or found some documentation about it? On Tuesday, March 4, 2014 10:02:50 PM UTC+3, Dave Aronson wrote: On Tue, Mar 4, 2014 at 1:13 PM, bertly_the_coder muc...@gmail.com wrote: They all pass. That's the problem. Mass-assignment doesn't seem to get caught by the testing environment. Ah, yes, that is odd. Maybe you could check out the tests from that part of Rails, or of the strong_parameters gem, and see how they do it. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us); FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014; creator of Pull Request Roulette, at PullRequestRoulette.com. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/26c2181f-9cf3-4608-a002-d923746d591c%40googlegroups.comhttps://groups.google.com/d/msgid/rubyonrails-talk/26c2181f-9cf3-4608-a002-d923746d591c%40googlegroups.com?utm_medium=emailutm_source=footer . For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BsTbysPrb8NLAFbUBF2F6jYNG4sLA%2BQTfVjTUe-YaFdfh5T9g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] How to get around a reserved word
I need to use the model name 'Action' (which will not work in Rails 4.0.3) for business reasons (it's a product name). If I name the actual model something else, is there any way to (maybe with mod_rewrite) make the URL appear the way I need it to while keeping everything working in Rails? I've tried using the controller flag in routes.rb to try to fix this, and it seems to work, but causes a lot of problems elsewhere -- basically anything where I use the automatic URLs, like link_to 'Link text', @instance_var needs to be rewritten to use the long-hand route helper, like this link_to 'Link text', action_path(@instance_var) What am I missing here? Thanks in advance, Walter -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3B7C311D-8FA4-40E7-ACCB-AEC9C499F9C9%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Rails] How to get around a reserved word
Namespace it? Product::Action for the model, and product_action_path(@instance_var) in the routes. On Wed, Mar 5, 2014 at 12:32 PM, Walter Lee Davis wa...@wdstudio.comwrote: I need to use the model name 'Action' (which will not work in Rails 4.0.3) for business reasons (it's a product name). If I name the actual model something else, is there any way to (maybe with mod_rewrite) make the URL appear the way I need it to while keeping everything working in Rails? I've tried using the controller flag in routes.rb to try to fix this, and it seems to work, but causes a lot of problems elsewhere -- basically anything where I use the automatic URLs, like link_to 'Link text', @instance_var needs to be rewritten to use the long-hand route helper, like this link_to 'Link text', action_path(@instance_var) What am I missing here? Thanks in advance, Walter -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3B7C311D-8FA4-40E7-ACCB-AEC9C499F9C9%40wdstudio.com . For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BsTbyvXGQy%2Bzjh_7kyBJjycd%3Do35spOQ%3DrMdeg4hryiMmb%2BUg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.