仅针对名称空间进行过滤之前的活动管理员 [英] Active Admin before filter for namespace only

查看:92
本文介绍了仅针对名称空间进行过滤之前的活动管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个命名空间 admin 。我只想将 before_filter 应用于此名称空间(而不是默认名称,即 superuser )。

I have a namespace admin. I would like to apply a before_filter only to this namespace (not the default one, which is superuser).

我可以在 active_admin.rb

ns.before_filter :is_subscribed?

但随后,超级用户得到了过滤器

我尝试在名称空间配置中添加 before_filter

I tried adding the before_filter inside my namespace configuration :

config.namespace :admin do |ns|
  ...
  ns.before_filter :is_subscribed?
end

但是Rails抛出错误:

but Rails throws an error :

undefined method `before_filter' for #<ActiveAdmin::Namespace:0x007fa2e0f75f00>


推荐答案

您可以添加一个带有before_filter的控制器,然后在所有

You could add a controller with that before_filter then in all the controllers in that namespace inherit from that controller?

即,该命名空间中的控制器是否继承自该控制器? AdminBaseController。

Ie. AdminBaseController.

这篇关于仅针对名称空间进行过滤之前的活动管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆