问题描述
我正在使用设计和最近添加的活动管理员,它创建了一个单独的 admin_users 表来保留管理员.
I am using devise and recently added active admin, which created a separate table of admin_users to keep admins.
当我尝试登录并浏览时,Active Admin 一切正常.但是,我的应用程序控制器为一般用户提供:
All works fine with Active Admin when I try to log in and browse around. However, my application controller has this for general users:
before_filter :authenticate_user!, :except => [:show, :index]
因此,在活动管理界面中,每当我尝试编辑或删除任何内容时,它都会要求我登录.我了解到可以在需要排除 before_filter 的控制器内部使用 skip_before_filter,但是 Active Admin 在我可以查看的控制器文件夹或我的项目中的任何地方都没有控制器文件.
Because of this, when inside the active admin interface, whenever I try to edit or delete anything, it asks me to log in. I learned that a skip_before_filter can be used inside the controller in which the before_filter needs to be excluded, however Active Admin doesn't have a controller file in the controllers folder or anywhere in my project I could look.
有人可以建议如何让活动管理员忽略我想应用于所有客户端/用户的应用程序 beofre_filter 吗?
can anyone suggest how to make active admin ignore the application beofre_filter which I want to apply on all of the client/user facing?
推荐答案
在 config/initializers/active_admin.rb
中,您可以添加以下内容:
In config/initializers/active_admin.rb
you can add the following:
config.skip_before_action :authenticate_user!
您还可以使用提供的 DSL 来修改 ActiveAdmin 控制器:http://activeadmin.info/docs/8-custom-actions.html#modify_the_controller
You can also use the DSL provided to modify the ActiveAdmin controller: http://activeadmin.info/docs/8-custom-actions.html#modify_the_controller
注意:对于 5.0 之前的 Rails 版本,您需要使用 skip_before_filter
.
Note: For Rails versions before 5.0 you will want to use skip_before_filter
.
这篇关于使用 Active Admin 过滤前跳过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!