On Apr 7, 2:19 pm, John Catalyne <li...@ruby-forum.com> wrote:
>
> I guess it's expecting me to build the city instance in the controller?

correct. field_for on an association that has nested attributes turned
on renders its block for each associated object.

> The way I got it to work is by doing this in my model:
>
> def city_attributes=(attribs)
>   self.city = City.find(attribs[:id])
> end
>
> Is there no other way?

It might be easier to just have a city_id virtual attribute rather
than trying to bend accepts_nested_attributes_for (given that you are
currently overriding all of the stuff it gives you)

Fred

>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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