I keep getting the error below when I use validations with collection_select. You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.inject Extracted source (around line #22): 19: <td>Vendor</td> 20: <td> 21: <!-- vendors --> 22: <%= collection_select("pricing_survey", "vendor_id", @vendors, :id, :vendor_name, { :prompt => true } ) %></td> 23: </tr> 24: <tr> 25: <td>Retailer</td> Does anybody have any ideas? I assume that rails is not querying the DB for the collection for my drop downs when an error occurs. Thanks, Phill
In the new and update methods of your controller (presumably pricing_survey_controller?) you should have something like @vendors = Vendor.find(:all). -- Posted via http://www.ruby-forum.com/.
Phillip Novess
2006-May-15 21:31 UTC
[Rails] Re: collection_select and validation problems
I have that for the new and edit methods but not the update and create methods. I saw somewhere else that I need to explicitly call the new method from within create. So instead of: else render :action => ''new'' end Do this..... else new render :action => ''new'' end However, now Iose my validation messages. Also it doesn''t seem to conform to the DRY method if I''m calling find in every method within my controller. Any other suggestions? Thanks, phill On May 15, 2006, at 11:27 AM, oom tuinstoel wrote: In the new and update methods of your controller (presumably pricing_survey_controller?) you should have something like @vendors = Vendor.find(:all). -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails