S. Robert James
2007-Apr-30 20:44 UTC
ActiveRecord: removing validations or callbacks on a subclass
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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rick Olson
2007-Apr-30 21:23 UTC
Re: ActiveRecord: removing validations or callbacks on a subclass
On 4/30/07, S. Robert James <srobertjames-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---