There may come a time that you wish to programatically get a list of what before_filters, after_filters, and around_filters are set on a given controller class in Rails. In Rails 2, there was a filter_chain
method on ActionController::Base
that you could use to do this. That method is gone in Rails 3 in favor of something much more magical.
One reason for wanting to do this is simply for debugging. Sometimes you just need to sanity check that filters are being applied in the order you think they are. Especially when they’re being added dynamically by various plugins.
In Rails 3, I find it convenient to add a few utility methods to ApplicationController
that list out the symbol names of all the filters on any given controller:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
With that in hand, you can do something like this:
1 2 3 4 5 6 7 8 9 10 11 |
|