John Woods
2010-Jan-26 23:01 UTC
Nested resource with nested models -- nested models not saved in child classes.
I have a nested model, Experiment, with accepts_nested_attributes_for :sources, and I was creating it and its sources in a single form using forms_for and fields_for. (Also, some JS to add/remove sources.) Matrix has_many :experiments, also. It worked great. Then I tried to make it a nested resource (inside of Matrix, e.g., matrices/1/experiments/new). It took a while, but I finally got the form_for working again like so: form_for([@matrix, @experiment]) do |f| Fine, okay. Then, I created new classes which inherited from Experiment -- Predictor and Distribution. I can create new predictors with sources. Works fine. Unfortunately, editing fails, even though the form code is exactly the same (a partial). I can edit or create new distributions, but any sources I include are absent at the end of the save. They show up in the params hash, but don''t appear to be saved. Is this a problem with my use of fields_for / nested-resources, or is it a problem with inheritance? Anyone seen anything like this before? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.