Hey Colin, > If you use collection_select on its own you need to pass the object, > but f.collection_select inside a form_for takes the object from > form_for.
Awesome insight! Thanks. I've been trying for days to dig myself out of this blunder. Idle question: Do you know whether that distinction is actually mentioned somewhere? I'll search for it in http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html Serious question. I deleted the first argument (the object) and ran the app successfully: 1. created a new expense 2. created a new vendor for this expense 3. selected the new vendor from the drop-down list 4. saved the expense The problem: The vendor field of the expense record is nil.. I expected a vendor_id there! I need one last (I hope) idea. Some details below Thanks in advance, Richard . On Jul 16, 3:39 pm, Colin Law <clan...@googlemail.com> wrote: > On 16 July 2010 20:31, RichardOnRails > > > > <richarddummymailbox58...@uscomputergurus.com> wrote: > >> Post back if you have any more problems. > > Thanks for your generous offer. So here's my last (I hope) stumbling > > block. I got: > > > NoMethodError in Expenses#new > > > Showing app/views/expenses/new.html.erb where line #14 raised: > > > undefined method `merge' for :nickname:Symbol > > > Extracted source (around line #14): > > > 11: <%# New version of vendor selection -%> > > 12: <% params[:expense] = 10 -%> > > 13: <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > > 14: <%= f.collection_select(:vendor, :id, > > @vendors, :id, :nickname) %> > > 15: <%# End of New version -%> > > 16: > > 17: <%#= f.collection_select(:vendor, @vendors, :id, :nickname) %> > > > But the claim about nickname being bogus seems suspicious to me. For > > one thing: > > >>> Vendor.find(:first) > > => #<Vendor id: 62, nickname: "vendor 5/15/2010", qbname: "Test new > > field names", [snip] > > > And the arguments seem to agree with > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelp..., > > particularly the guidance for the public instant method: > > > collection_select(object, method, collection, value_method, > > text_method, options = {}, html_options = {}) > > If you use collection_select on its own you need to pass the object, > but f.collection_select inside a form_for takes the object from > form_for. > > The documentation is a bit confusing in that area. > > Colin > > > > > Any ideas? > > > Thanks in Advance, > > Richard > > > On Jul 16, 11:58 am, Andy Jeffries <a...@andyjeffries.co.uk> wrote: > >> > > Welcome to dynamic objects and classes :-) > >> > Thanks. This restores my faith in Rails and enhances my appreciation > >> > of newsgroups, especially this one. > >> > Now I've got to put them to use! > > >> Good luck. > > >> Post back if you have any more problems. > > >> Cheers, > > >> Andy > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.