Just noticed I had a typo. Forgot to include "has_many :homes" in Person model. Fixed below.
Any advice on where to update the nested objects? Thanks in advance, Mike On May 4, 6:43 am, Mike <[email protected]> wrote: > Hi, > > I have a model with nested objects similar to this: > > class Person < ActiveRecord > has_many :addresses > has_many :homes > accepts_nested_attributes_for :addresses > accepts_nested_attributes_for :home > end > class Address < ActiveRecord > belongs_to :person > has_one :home > end > class Home < ActiveRecord > belongs_to :person > belongs_to :address > end > > In my form, I'd like to offer the user the option of selecting the > address and home from a selection or add a new home/address in a text > field. If a home/address is selected in the selection, I want to > ignore the text field. If the renamed blank field is selected, then > grab the text field. If the value in the text field is already used, > then reuse the ID. I'd also like to propagate the "address" and > "person" values to home, but it seems I can only do one or the other > with build. > > I've been able to get all the form magic to work, but saving doesn't > go as planned. I have to intercept the save, but I'm not sure where > the best place is. Do I override "new" and "update" or do a > "before_save" or ... ? > > Thanks in advance, > Mike > > -- > 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 > 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 [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.

