-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
class Person include Mongoid::Document has_and_belongs_to_many :followers, class_name: "Person", inverse_of: :followee, after_add: :follower_added has_and_belongs_to_many :followees, class_name: "Person", inverse_of: :follower, after_add: :followee_added def method_missing(method, *args) puts "#{method}(#{args})" end end p1, p2 = [Person.create, Person.create] p1.followers << p2
Expected:
follower_added([#<Person _id: 511f9ea46fae9b13a6000004, follower_ids: nil, followee_ids: ["511f9ea46fae9b13a6000003"]>]) followee_added([#<Person _id: 511f9ea46fae9b13a6000003, follower_ids: ["511f9ea46fae9b13a6000004"], followee_ids: nil>])
Actual:
follower_added([#<Person _id: 511f9ea46fae9b13a6000004, follower_ids: nil, followee_ids: ["511f9ea46fae9b13a6000003"]>])
Not sure if this is actually a bug or instead by design, but I think it would be more consistent (and thus expected) if the callbacks would also fire on the inverse relationship.
(Keywords: 1-n, n-n relations after_add, after_remove, before_add, before_remove)