class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :check_session_expiry, :except => :login
你如何排除單控制器(用戶控制器,例如)登錄動作?如何從Rails 3.07中的過濾器中排除單個控制器動作?
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :check_session_expiry, :except => :login
你如何排除單控制器(用戶控制器,例如)登錄動作?如何從Rails 3.07中的過濾器中排除單個控制器動作?
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
首先,我不是軌測試它的機器上,但下面應該工作:
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
是的!有用!謝謝:) – hlegius