The problem is that you have two relationships with the same name, and you need the opposite relationship for your has_one :user relationship. You can always try something like this:
class User include Mongoid::Document has_many :subscriptions has_many :subscribers, :class_name => "Subscription", :inverse_of => :subscriber end class Subscription include Mongoid::Document field :category belongs_to :owner, :class_name => "User", :inverse_of => :subscriptions belongs_to :subscriber, :class_name => "User", :inverse_of => :subscribers end
Then you should be able to do things like:
> user1.create_subscription(:subscriber => user2, :category => "Test") > user1.subscriptions.where(:subscriber => user2).delete_all
theTRON
source share