# Nested resource with nested models -- nested models not saved in child classes

**URL:** <https://www.ruby-forum.com/t/nested-resource-with-nested-models-nested-models-not-saved-in-child-classes/182355>\
**Category:** Rails\
**Created:** [January 27, 2010, 12:03am UTC](https://www.ruby-forum.com/t/nested-resource-with-nested-models-nested-models-not-saved-in-child-classes/182355 "2010-01-27T00:03:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![princenamor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@princenamor](https://www.ruby-forum.com/u/princenamor)\
**Post date:** [January 27, 2010, 12:03am UTC](https://www.ruby-forum.com/t/nested-resource-with-nested-models-nested-models-not-saved-in-child-classes/182355/1 "2010-01-27T00:03:12Z")

</div>

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?
