Classic Associations

suggest change

Mongoid allows the classic ActiveRecord associations:

To add an association (for example, a user has_many posts), add this to the User model:

has_many :posts

and this to your Post model file:

belongs_to :user

This will add a user_id field in your Post model, add a user method to your Post class, and add a posts method to your User class.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents