ActiveRecord: removing validations or callbacks on a subclas

Often a parent class has validations (or callbacks or associations)
which I don’t want the subclass to have. Is there any simple way to
remove these?

On 4/30/07, S. Robert J. [email protected] wrote:

Often a parent class has validations (or callbacks or associations)
which I don’t want the subclass to have. Is there any simple way to
remove these?

Not really. Just don’t add them. If you have 5 sub classes, and only
3 of them need the validations or callbacks, set it up in a special
mixin:

module PickyCallbacks
def self.included(base)
base.after_save :foo
base.validates_format_of :email, :with => /…/
end
end


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com