Suppose you have a Rails controller with a before_filter:
If you’ve deleted the
frobnicate action, Rails won’t complain; that symbol will just sit around
in your controller adding to the file noise. Furthermore, if you removed both methods specified in the
only block then the
load_widget method would be unused and gathering dust as well. FilterDecrufter to the rescue!
How to use it
To use it, add FilterDecrufter to your
Gemfile in the
and then run the task:
1 2 3
How does it work?
around_filter by defining a singleton method on
ApplicationController for each filter type. As it proxies those method invocations, it also records the
except arguments for future analysis.
Once the metaprogramming is done, FilterDecrufter loads up all the controllers (with
Rails.application.eager_load!) which triggers calls to the filter method proxies. The proxies gather the data, the reporting mechanism compares the filter arguments to the output of
AbstractController::UrlFor::ClassMethods.action_methods, and the old action names are printed out so you can get them squared away.