2016-05-13 111 views
0
class UserSessionsController < ApplicationController 
    skip_before_action :require_login, except: [:destroy] 

    def new 
    ... 
    end 

    def create 
    ... 
    end 

    def destroy 
    logout 
    redirect_to signin_path , flash: { info: 'Bye!' } 
    end 
end 

class ApplicationController < ActionController::Base 
    before_action :require_login 

    private 
    def not_authenticated 
    redirect_to signin_path, flash: { danger: "ALARM!" } 
    end 
end 

註銷後,我被重定向到登錄頁面,並顯示「ALARM」消息。 之後,當我再次登錄時,我被重定向到登錄頁面,並顯示「再見!爲什麼Session#Destroy觸發not_authenticated動作?

請幫忙!

回答

0

好吧,這是某種巫術錯誤。你只需要在destroy會議之前跳過require_login

相關問題