I have two models
class Supplier < User
include Mongoid::Document
embeds_many :images
accepts_nested_attributes_for :images
end
class Image
include Mongoid::Document
embedded_in :supplier
end
When I save images in nested form it gets save embeded in supplier collection i.e
s = Supplier.first
s.images #some Image records
But the problem is image collection itself remains empty i.e
Image.count # gives 0
The documents of your
Imagemodel are stored inside the document of yourSuppliermodel. So basically there is no collection with nameimagescreated in mongo. Check that in your mongo console. You only will be having asupplierscollection and noimagescollection.If you want to access Images directly without accessing a particular you can do this
Or implement
has_many