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