Created
June 27, 2011 16:01
-
-
Save trivektor/1049151 to your computer and use it in GitHub Desktop.
Skip callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Courtesy http://www.allerin.com/blog/?p=186 | |
class ActiveRecord::Base | |
def self.skip_callback(callback, &block) | |
method = instance_method(callback) | |
remove_method(callback) if respond_to?(callback) | |
define_method(callback){ true } | |
yield | |
remove_method(callback) | |
define_method(callback, method) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment