I have a Team class that inherits from a Group class. Both Team and Groups have memberships through the same association. However, I need to run a method after a Team memberships is added but not a Group. I currently have something like this:
class Group < ActiveRecord::Base
has_many :memberships,
:class_name => 'Connection',
:foreign_key => 'connectable_id',
:as => :connectable,
:dependent => :destroy
end
class Team < Group
has_many :memberships,
:class_name => 'Connection',
:foreign_key => 'connectable_id',
:as => :connectable,
:dependent => :destroy,
:after_add => :add_company_membership
private
def membership_check(membership)
end
end
Is there some way to modify the inherited association in Team so that I don't have to redefine the entire thing but rather just add the :after_add hook it?
Any help would be appreciated.