skip callback in inherited model

abstract-class, callback, ruby-on-rails

Solution

class Message < Parent
  skip_callback :create, :after, :notify
end

Check Rails Documentation for details

Problem

Is there a method like `ActionController::Base#skip_before_filter` for ActiveRecord callbacks like `after_create`? I have a few classes that behave similarly, and to reduce code repetition I created an abstract class. The abstraction contains relation information, validation and an `after_create` callback that creates a new message. `Message` implements this abstractions, so saving the message causes an stack overflow. Can I remove a callback from a model? ``` class Parent < ActiveRecord::Base self.abstract_class = true after_create :notify def notify Message.create end end class Message < Parent # skip after_create :notify end class Child < Parent end ```

Original source