can anyone tell me how to skip all before filters in rails 3.
In rails 2.x we could do
skip_filter filter_chain
however filter_chain is no longer supported in rails 3.
Thanks
For Rails 5, I've used
class SomeController < ApplicationController
skip_before_action *_process_action_callbacks.map{|callback| callback.filter if callback.kind == :before}.compact
You must check the callback.kind, otherwise _process_action_callbacks will return all callbacks, including after
and around
, which will raise an exception with skip_before_action
method.
The .compact
at the end removes nils
from the resulting array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With