在Rails中的同一个控制器中验证两个不同的设计类

时间:2015-06-13 05:18:10

标签: ruby-on-rails ruby devise

我有一个名为Intranet的视图,其中只有经过身份验证的“设计客户端”才能访问。

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

另一方面,我还有其他“设计管理员”,这个设计管理员需要访问相同的视图。我该如何处理这种情况?

1 个答案:

答案 0 :(得分: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