目前我有User模型,它user.rb作为ActiveAdmin的新资源注册.生成的页面显示具有范围(all/ journalists/ startup_employees)的所有用户.现在我想创建另一个页面相同的资源,和相同的范围,但应该只记录与waiting字段设置为true(和以前的页面应该只有这与显示器:waiting => false).我怎么能这样做?我知道我可以用过滤器做到这一点,但我需要两个单独的页面,菜单中有两个链接.
//解决方案
它甚至比建议更容易(谢谢你们!):
ActiveAdmin.register User, :as => 'Waitlist User' do
menu :label => "Waitlist"
controller do
def scoped_collection
User.where(:waitlist => true)
end
end
# code
scope :all
scope :journalists
scope :startup_employees
end
Run Code Online (Sandbox Code Playgroud)
ActiveAdmin.register User do
controller do
def scoped_collection
User.where(:waitlist => false)
end
end
# code
scope :all
scope :journalists
scope :startup_employees
end
Run Code Online (Sandbox Code Playgroud)