我正在尝试用Rails 4在ActiveAdmin(1.0.0pre4)中创建一个选择类别过滤器。每个公司都有不同的类别。如何创建基于current_user公司的过滤器集合?
filter :by_category,
as: :select,
collection: proc { Category.by_company(current_company) }这会产生一个undefined method 'map' for #<Proc:0x007fccc3b29340>
如果我删除了周围的proc,那么当我启动服务器时,我得到了以下错误:
undefined local variable or method 'current_company' for #<ActiveAdmin::ResourceDSL:0x007fb8a8c332b0> (NameError)使用ActiveAdmin 1.0.0pre4可以做到这一点吗?
发布于 2016-11-29 13:16:21
你能从current_user得到current_company吗?ie current_user.company
如果是这样,
filter :by_category,
as: :select,
collection: proc { Category.by_company(current_user.company) }https://stackoverflow.com/questions/40854558
复制相似问题