ruby on rails - How to store ObjectID in MongoDb without references? -
i have 3 models:
class user include mongoid::document field :name, :type => string has_many :comments embeds_many :posts end class post include mongoid::document field :title, :type => string field :body, :type => string embeds_many :comments belongs_to :user end class comment include mongoid::document field :text, :type => string belongs_to :user embedded_in :post end and have error:
referencing a(n) comment document user document via relational association not allowed since comment embedded. ok, thats right. how can store, wrote comment?
the belongs_to user in comment what's throwing off. use normal field store foreign key.
class comment include mongoid::document embedded_in :post field :text, :type => string field :commenter_id end
Comments
Post a Comment