2015-06-13 38 views
0

我有一個稱爲Intranet的視圖,只有經過驗證的「設計客戶端」才能訪問。在Rails的相同控制器中驗證兩個不同的設計類

class IntranetController < ApplicationController 
    before_action :authenticate_client! 
    def index 
    end 
end 

在另一邊,我也有其他的「設計管理」,這個色器件管理員要求訪問同樣的觀點。我該如何處理這種情況?

+1

http://stackoverflow.com/questions/4612545/devise-login-with-user-or-admin-models-and-basecamp-style-subdomains –

回答

1

試試這個:

class IntranetController < ApplicationController 
    before_action :authenticate_all! 
    def index 
    end 
    def authenticate_all! 
    if admin_signed_in? 
     true 
    else 
     authenticate_client! 
    end 
    end 
end 
相關問題