Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 跳过一个控制器上的审核范围_Ruby On Rails 4_Pundit - Fatal编程技术网

Ruby on rails 4 跳过一个控制器上的审核范围

Ruby on rails 4 跳过一个控制器上的审核范围,ruby-on-rails-4,pundit,Ruby On Rails 4,Pundit,我想跳过一个控制器(主控制器)上的权威的策略范围要求。我试过这个: class ApplicationController < ActionController::Base include Pundit after_action :verify_authorized, :except => :index, unless: :devise_controller? after_action :verify_policy_scoped, :only => :index,

我想跳过一个控制器(主控制器)上的权威的策略范围要求。我试过这个:

 class ApplicationController < ActionController::Base
  include Pundit
  after_action :verify_authorized, :except => :index, unless: :devise_controller?
  after_action :verify_policy_scoped, :only => :index, unless: controller.controller_name == "home"
 end

 class HomeController < ApplicationController
   def index
     redirect_to (new_user_session_path) unless user_signed_in?
     if user_signed_in?
       @user=current_user
     end
    end
  end
class ApplicationController:index,except::设计\u控制器?
在\u操作之后:验证\u策略\u作用域,:only=>:index,除非:controller.controller\u name==“home”
结束
类HomeController<应用程序控制器
def索引
除非用户\u登录,否则是否将\u重定向到(新用户\u会话\u路径)?
如果用户已登录?
@用户=当前用户
结束
结束
结束

但是我认为控制器还没有定义或者什么的?有什么想法或建议吗?

我通过在home controller中添加一个“后跳过”操作来完成这项任务:

class HomeController < ApplicationController
  skip_after_action :verify_policy_scoped, :only => :index
end
class HomeController:index
结束

自1.0.0版以来,您可以在控制器操作中使用
跳过策略范围