You can achieve what you want using the class_name and inverse_of options:
class Account include Mongoid::Document field :name has_many :ratings_given, :class_name => 'Ratings', :inverse_of => :rater has_many :my_ratings, :class_name => 'Ratings', :inverse_of => :ratee end class Ratings include Mongoid::Document field :name belongs_to :rater, :class_name => 'Account', :inverse_of => :ratings_given belongs_to :ratee, :class_name => 'Account', :inverse_of => :my_ratings end
The documentation has changed since the last time I worked with it, so I was not sure if this is still recommended. It seems that these options are not mentioned on page 1- many links. But if you look at the general relations page , they will be covered there.
In any case, you need to explicitly link the ratings_given / rater and my_ratings / ratee associations when there are two associations with the same class, otherwise mongoid has no way of knowing which of the two potential inversions to choose.
source share