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 professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
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)