【问题标题】:active_admin toggle scope with filteractive_admin 使用过滤器切换范围
【发布时间】:2014-12-15 17:25:38
【问题描述】:

我有一个活动的管理页面,我希望有一个过滤器来切换范围的使用:

class Foo < ActiveRecord::Base
  scope :bar, where( ... )
end

ActiveAdmin.register Foo do
  filter :bar, :as => :select, :collection => {:true => nil, :false => false }
end

但我得到undefined methodbar_eq' 为#

即使我在 Foo 上定义了范围 bar_eq,我仍然会得到它。

如何在 active_admin 中打开和关闭范围

【问题讨论】:

    标签: ruby-on-rails activeadmin


    【解决方案1】:
    class Foo < ActiveRecord::Base
      scope :bar, where( ... )
    end
    
    ActiveAdmin.register Foo do
      scope :all, default: true
      scope :bar
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-15
      • 1970-01-01
      • 2014-05-21
      • 2013-04-19
      • 1970-01-01
      • 1970-01-01
      • 2017-02-12
      • 1970-01-01
      相关资源
      最近更新 更多