I need to implement a before_action
callback in my application controller only for activeadmin and devise controllers. For devise controllers I can do something like:
before_action :some_callback, if: :devise_controller?
How can I do the same for activeadmin controllers? I tried to make a method like:
def active_admin_controller?
if params[:controller] =~ /^admin\//i
true
end
end
but it doesn't work. Any ideas on how to reach the desired result? Thanks ahead.
I've found the solution, just had to put the conditions into an array:
before_action :some_callback, unless: [:devise_controller?, :active_admin_controller?]
also, changed active_admin_controller?
method:
def active_admin_controller?
if request.filtered_parameters['controller'] =~ /^admin\//i
true
else
false
end
end