简体   繁体   中英

active_admin toggle scope with filter

I have an active admin page that I would like to have a filter that toggles the use of a scope:

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

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

but I get undefined method bar_eq' for #

and I still get that even if I define a scope bar_eq on Foo.

How can I toggle a scope on and off in active_admin

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

ActiveAdmin.register Foo do
  scope :all, default: true
  scope :bar
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM