Last active
December 17, 2015 04:19
-
-
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.
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
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should make you feel gross.