On Apr 7, 10:43 am, John Catalyne <li...@ruby-forum.com> wrote:
> If I put f.fields_for :city, this gets generated:
>
> <select name="user[city][id]" id="user_city_id">
>
> and I get an AssociationMismatch saying
> ActiveRecord::AssociationTypeMismatch: City(#36862620) expected, got
> Hash(#21169932)
>
> If I put f.fields_for :city_attributes, this gets generated:
>
> <select name="user[city_attributes][id]" id="user_city_attributes_id">
>
> Which looks more like what the nested form would accept.
>

With accepts_nested_attributes you always just use the association
name - you don't need to mangle things. Also I'm slightly confused by
your models / form. Does a city really belong to a unique user ?

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

Reply via email to