Skip to content

Instantly share code, notes, and snippets.

@amar47shah
Created June 6, 2016 19:54
Show Gist options
  • Save amar47shah/3fcd4dc8b63494640dc86b4b28bf364a to your computer and use it in GitHub Desktop.
Save amar47shah/3fcd4dc8b63494640dc86b4b28bf364a to your computer and use it in GitHub Desktop.
# View
model = MY_MODEL_NAME
model.methods.select { |method| method.to_s =~ /^_{1}[^_].+_callbacks$/ }
.each_with_object({}) { |method, memo| memo[method] = model.send(method).group_by(&:kind)
.each { |_, callbacks| callbacks.map! { |callback| callback.raw_filter } } }
# Nuke
%i(initialize validate create update save destroy validation find touch commit rollback).each do |event|
reset_callbacks event
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment