hi
I have a form that has a category model and and embeded docuement called "FieldModule" and this has embedded document called "SubFieldModule"
For example
class Category
include MongoMapper::Document
key :name, String
many :field_modules
end
class FieldModule
include MongoMapper::EmbeddedDocument
key :name, String
many :sub_field_modules
end
class SubFieldModule
include MongoMapper::EmbeddedDocument
key :name, String
end
In my controller i edit action i have :
@category = Category.find(params[:id])
3.times do
@category.field_modules << FieldModule.new()
end
To set up 3 FieldModules for the category.
I want to be able to do the same for each FieldModules SubFieldModules like so
@category.field_modules.each do |mf|
mf << SubFieldModule.new()
end
but it doesnt work.
i get error:
NoMethodError in Sub categoriesController#edit
undefined method `<<' for #<FieldModule name: nil, _id: $oid4c2b9f594248ce19f000011b>
Anyone help me out on this ? as i then need to take it one level deeper doing the same.