What is the best way to add action after a belongs_to assignment? (Just
like ‘after_add’ in has_many assignment).
I see that there is no callbacks for belongs_to.
I have tried overriding parent= :
alias :parent_before_mod= :parent=
parent_before_mod = the_parent
# my actions here
but when I tried to assign parent, parent_id was not changed.
Can someone help?
class Company < ActiveRecord::Base
has_many :children, :class_name => ‘Company’, :foreign_key =>
:after_add => :after_add_child, :before_remove =>
belongs_to :parent, :class_name => ‘Company’, :foreign_key =>
something similar to :after_add above?