使用Active Admin过滤前跳过

我正在使用设计和最近添加的活动管理员,它创建了一个单独的admin_users表来保持管理员。

当我尝试登录并浏览时,一切正常。 但是,我的应用程序控制器对一般用户有此:

before_filter :authenticate_user!, :except => [:show, :index] 

因此,当在活动管理界面内时,每当我尝试编辑或删除任何内容时,它都会要求我登录。我了解到可以在需要排除before_filter的控制器内部使用skip_before_filter,但是Active Admin控制器文件夹中没有控制器文件,或者我可以看到项目中的任何位置。

任何人都可以建议如何使活动管理员忽略应用程序beofre_filter我想应用于所有面向客户端/用户?

config/initializers/active_admin.rb您可以添加以下内容:

 config.skip_before_action :authenticate_user! 

您还可以使用提供的DSL来修改ActiveAdmin控制器: http ://activeadmin.info/docs/8-custom-actions.html#modify_the_controller

注意:对于5.0之前的Rails版本,您将需要使用skip_before_filter

我无法获得@ coreyward的解决方案,但根据此Devisepost编辑config/application.rb并添加:

 ActiveAdmin.register_page "Dashboard" do controller do skip_before_action :name_of_filter_to_skip end # Other code end 

admin/dashboard.rb做了这个伎俩。 仅通过编辑config/application.rb无法正常工作。 确保重新启动服务器!

corey和Sooie都是正确的…但只是部分,以阻止你的毯子authorize_user! 过滤影响active_admin你需要实现他们的答案……

配置/初始化/ active_admin.rb

 config.skip_before_filter :authorize_user! 

应用程序/管理/ dashboard.rb

 controller do skip_before_filter :authorize_user! end 

我无法使@fringd和@coreyward的解决方案适用于Rails4(使用ActiveAdmin master分支)。

所以,我已经将filter方法(我有两个filter: authorize_user!check_user_status )移动到一个新的Concern,并将这个创建的模块包含在具有这些filter的控制器中( ApplicationController除外 ,它应该保持干净)。

然后重新启动服务器,问题解决了。