2011-08-27 2 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

첫째, 나는 그것을 테스트하는 레일 시스템에 아니지만, 다음과 같은 작동합니다 : 난 그냥 비어있는 방법으로 컨트롤러에 check_session_expiry을 재정의 할

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

yep! 그것은 작동합니다! 감사합니다 :) – hlegius

2

.

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

관련 문제