Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/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 前过滤器:除设计动作不起作用外_Ruby On Rails_Devise_Before Filter - Fatal编程技术网

Ruby on rails 前过滤器:除设计动作不起作用外

Ruby on rails 前过滤器:除设计动作不起作用外,ruby-on-rails,devise,before-filter,Ruby On Rails,Devise,Before Filter,每个新用户都必须接受EULA才能使用我的RoR应用程序提供的服务,因此当用户首次登录我的网站时,他/她必须接受EULA,如果他/她不想接受,他/她可以直接注销,因此: 我在我的应用程序控制器中有一个前置过滤器,带有:除了操作: before_filter :check_eula, :except => [:destroy] 我的EULA页面上有一个链接: <%= link_to('Logout', destroy_user_session_path, :method => :

每个新用户都必须接受EULA才能使用我的RoR应用程序提供的服务,因此当用户首次登录我的网站时,他/她必须接受EULA,如果他/她不想接受,他/她可以直接注销,因此:

我在我的
应用程序控制器中有一个
前置过滤器
,带有
:除了
操作:

before_filter :check_eula, :except => [:destroy]
我的EULA页面上有一个链接:

<%= link_to('Logout', destroy_user_session_path, :method => :delete, :class => link_class) %>

问题是,当用户在不接受eula的情况下单击“注销”链接时,
:check_eula
似乎仍然被调用。

我不知道为什么以下操作会起作用,但下面是解决方案:

config/application.rb
中:

config.to_prepare do
  # ...

  Devise::SessionsController.skip_before_filter :check_eula, :only => [:destroy]
end
参考:

config.to_prepare do
  # ...

  Devise::SessionsController.skip_before_filter :check_eula, :only => [:destroy]
end