class Project << ActiveRecord::Base
class File << ActiveRecord::Base
Inside of the project model, when creating a new product, I want to
store the hierarchy of files within it.
If I do,
my_top_level_file = my_project_object.files.create(:file_name =>
my_top_level_file.children.create(:file_name => ‘bar’)
When the data gets saved, the first row in the Files table gets the
new product_id value that is also inserted into the Projects table,
but the child row does not, giving me results like:
product_id: 0 <---------------------- Should this not be 1?
Firstly, am I doing things right? If so, is this a bug, or is this
how things were intended to work? Surely all rows in the files table
should have the correct foreign key attached to them?