revealing the ActionController callback filter chain

February 1, 2011 Nate Clark

Sometimes your controllers get so full of before_filters, after_filters, and around_filters that it’s hard to figure out what order these callbacks are actually executing in. A couple of times recently, I’ve run into some tricky bugs that ended up being related to callbacks running too soon or too late.

Due to some fancy-pants metaprogramming in AbstractController::Callbacks, it’s hard to see what’s going on.

In Rails 3, send this to Rails.logger.debug or puts from inside your controller to see the ordered filter callback chain:

_process_action_callbacks.map(&:filter)

About the Author

Biography

More Content by Nate Clark
Previous
Pairing in Boulder
Pairing in Boulder

Recently, we have been experimenting with a few new pairing configurations in Boulder, I thought I would sh...

Next
Don't Sweep It Under the Rug
Don't Sweep It Under the Rug

Advice for Rails Performance Optimization Upcoming Launch Recently, our team releasing to a large set of ...