2011-08-27 41 views

回答

2
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 
5

首先,我不是軌測試它的機器上,但下面應該工作:

class UserController < ApplicationController 
    skip_filter :check_session_expiry, :only => :foo 

    # following is DEPRECATED as far as I know 
    #skip_before_filter :check_session_expiry, :only => :foo 

    def foo 
    end 
end 
+0

是的!有用!謝謝:) – hlegius

2

我只想重新定義check_session_expiry在你的控制器是一個空的方法。

class UserController < ... 
    ... 
    private 
    def check_session_expire 
     # optional if other actions shall still use the filter 
     super unless self.action == 'login' 
    end 
    end 
+0

但其他控制器操作有什麼?過濾器比沒有運行的那些。 OP只想跳過一個動作的過濾器。 – Deradon

+0

對不起,我以爲他想過濾器完全刪除。 – ayckoster

相關問題