Classic Associations

suggest change

Mongoid allows the classic ActiveRecord associations:

To add an association (lets say the User has_many posts), you can add this to your User model file:

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