Skip to content

Instantly share code, notes, and snippets.

@linjian
Created July 19, 2012 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linjian/3141357 to your computer and use it in GitHub Desktop.
Save linjian/3141357 to your computer and use it in GitHub Desktop.
Without Callback
# Put it in config/initializers/without_callback.rb
#
# Usage:
# Site.without_callback(:destroy, :after, :decrease_sites_count) do
# ...
# end
module ActiveSupport::Callbacks::ClassMethods
def without_callback(*args, &block)
skip_callback(*args)
yield
set_callback(*args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment