On Jul 13, 2:03 pm, RichardOnRails
<[email protected]> wrote:

> > Assuming Vendor belongs_to :expense then
> > f.collection_select :vendor_id, @vendors, :id, :name
> > would do the trick
>
> Au contraire:  My concept is that every Expense belongs to some
> Vendor.  However,  every Vendor can have many different Expenses
> (incurred, as it were, at various times).

Sorry I worded that one back to front
>
> But I like your f.collection statement,  though I feel I need to set
> @vendors somewhere to:
> @vendors = Vendor.find( :all, order=:>”nickname ASC”),
> perhaps just before the collection_select statement or in the Vendor’s
> controller (but within what method?)

you would indeed, typically within whatever action this is for (so in
this case the new method)
>
> Here’s what I wound up with in app\views\expenses\new.html.erb:
>     <%# New version of vendor selection -%>
>     <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%>
>     <%= f.collection_select(:vendor, :vendor_id,
> @current_vendors, :id, :nickname) %>
>     <%# End of New version -%>
>
> That gave me:
>     undefined method `merge' for :nickname:Symbol (referencing the
> collection_select line)
>

It's getting confused because the first argument to
collection_select(:vendor) shouldn't be there (so it thinks that your
last parameter is a hash of options, but it's the symbol nick_name
instead)

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to