Read more

Inspecting model callback chains

Arne Hartherz
October 14, 2010Software engineer at makandra GmbH

If you need to look at the list of methods that are called upon certain events (like before/after saving etc), do this:

Model._save_callbacks.select {|cb| cb.kind == :before}.map{ |c| c.instance_variable_get :@filter }

Rails 2

User.after_save_callback_chain
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To look at the method names only, you could do something like that:

User.after_save_callback_chain.collect(&:method)
Posted by Arne Hartherz to makandra dev (2010-10-14 12:23)