Skip to content

Instantly share code, notes, and snippets.

@rthbound
Last active December 17, 2015 04:19
Show Gist options
  • Save rthbound/5549730 to your computer and use it in GitHub Desktop.
Save rthbound/5549730 to your computer and use it in GitHub Desktop.
Paste this into the rails console and see the total number of callbacks your application has defined for its models.
Rails.application.eager_load!
models = ActiveRecord::Base.descendants.map(&:name)
callbacks = []
callback_types = %w{ _save_callbacks _create_callbacks _destroy_callbacks _validation_callbacks _commit_callbacks }
callback_types.each do |callback_type|
models.each do |model|
callbacks << instance_eval(model).send(callback_type)
end;nil
end;nil
puts "#{callbacks.flatten.count} total callbacks"
@rthbound
Copy link
Author

rthbound commented May 9, 2013

It should make you feel gross.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment