I have a before_filter
in my ApplicationController
; that is, for every controller in my project.
How can I skip_before_filter
Here's another way in lib/devise_sessions_controller_decorator.rb:
module DeviseSessionsControllerDecorator
extend ActiveSupport::Concern
included do
skip_before_filter :your_filter_name
end
end
Devise::SessionsController.send(:include, DeviseSessionsControllerDecorator)
Because classes are not cached in development mode, you may need to add something like this to config/environments/development.rb:
config.to_prepare do
Devise::SessionsController.send(:include, DeviseSessionsControllerDecorator)
end
You can simply check in your filter method whether it is devise controller or not.
if params[:controller] != 'devise/sessions'
what about wrapping the before_filter in an unless block filtering by params[:controller]
def some_before_action
unless params[:controller] == "sessions_controller_for_devise_name"
... #=> do the stuff here
end
end
just authorize which actions should use the before filter
before_filter :action, :only => ...
and authorize your others.
found this here
I recently had this problem with filter in my application_controller
I solved it using skip_before_filter
skip_before_filter :check_subdomain!, if: :devise_controller?
We did something like this:
First up, create your own session controller, make sure to inherit correctly:
class SessionsController < Devise::SessionsController
skip_before_filter :foobar
Then fix the routes
devise_for :users,
:controllers => {
:sessions => "sessions"
}
Alternatively you could monkey-patch Devise's session controller.
Here's a method my colleague just showed me:
# In config/application.rb
module YourAppNameHere
class Application < Rails::Application
# Whatever else is already here...
# The part to add
config.to_prepare do
Devise::SessionsController.skip_before_filter :your_before_filter_here
end
end
end