:except not working in before_filter in application controller. Routing problem?

后端 未结 1 418
情书的邮戳
情书的邮戳 2021-01-04 07:57

I have a before_filter in my application controller to keep a user\'s session alive (and log them out if a time out has been reached). This should be called on every action

相关标签:
1条回答
  • 2021-01-04 08:45

    The :except option takes action names, not url parts. Here's what you should do instead:

    class ApplicationController < ActionController::Base
      before_filter :update_activity_time
      ...
    end
    

    Then, in sessions_controller.rb:

    class SessionsController < ApplicationController
      skip_before_filter :update_activity_time, :only => [:new, :destroy]
      ...
    end
    

    You don't want to put the :except in ApplicationController because, if you did, the new and destroy actions for every one of your app's controllers wouldn't update the activity time.

    0 讨论(0)
提交回复
热议问题