Can you include before/after filters in a Rails Module? -
i wanted add method 2 models, made module , included in both models.
module userreputation def check_something ... end end
that worked fine. wanted have method called :after_create on models. works if add manually models, wanted smart , include in module this:
module userreputation after_create :check_something def check_something ... end end
but doesn't work. there way accomplish , dry after_create well?
try self.included, called when module mixed class base
:
module userreputation def self.included(base) base.after_create :check_something end end
Comments
Post a Comment