Ruby on Rails Sunday, February 27, 2011

On Feb 27, 5:12 pm, Michael Baldock <li...@ruby-forum.com> wrote:
>
> The text field is working fine, and creates new associated bands, but
> the collection_select selection isn't getting passed through correctly,
> and I'm very confused...
>
> (I got the code from R Bates's railscast on complex forms pt 2)

Not answering your question directly, but these days you probably want
to use the accepts_nested_attributes stuff that is built into rails
2.3 and higher.

>   =band_form.label "Select from saved Bands"
>   =collection_select(band, :saved_band_name, @bands, :band_name,
> :band_name, {:selected => @selected_band})

That first argument to collection_select should be the name of the
attribute, ie a symbol or string rather than an actual instance of
band. The easy way would be to use the form builder, ie
band_form.collection_form :saved_band_name, ... just like you're doing
with other form inputs

Fred

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

No comments:

Post a Comment