Hello all,
I just began using Mongoid last week. I am running into this association problem which I am unsure if my approach is correct. So i thought I would ask for some opinion
I have a User model and a Project model class User include Mongoid::Document field :email end class Project include Mongoid::Document field :name end
Actually the user model is created by Devise, an authentication gem, so I guess it cannot be embedded in Project.
So if I wanted the old many to many associations where a user can have many projects and a project can have many users. how should I set this up?
My approach is this: class User include Mongoid::Document field :email references_many :projects referenced_in :project, :inverse_of => :users end class Project include Mongoid::Document field :name references_many :users referenced_in :user, :inverse_of => :projects end
Is this the correct way with respect to MongoDB architecture to do such a many-to-many association?
Thank you