Search code examples
ruby-on-railsruby-on-rails-3before-filter

How to exclude a single controller action from a filter in Rails 3.07?


class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :check_session_expiry, :except => :login

How do you exclude a single controller's (the users controller, for example) login action?


Solution

  • class ApplicationController < ActionController::Base
      before_filter :check_session_expiry
    
    
      def check_session_expiry
         return true if self.class != UsersController && self.action == "login"
         # do your thing
      end