我在 ActiveAdmin 中有一个默认范围,不包括“待定”状态,因为我们有很多这种状态,而且我们不想在默认情况下看到它。但是当我们按过滤器搜索时,我们希望跳过这个默认范围并包括“待定”状态。这个怎么做 ?
我的模型:
class MyModel < ActiveRecord::Base
validates :status, presence: true,
inclusion: { in: %w(pending published accepted declined cancelled) }
scope :published, lambda {
where("bookings.published_at IS NOT NULL")
}
end
ActiveAdmin 模型:
ActiveAdmin.register MyModel do
actions :index, :show
config.sort_order = "locked_at_desc"
config.scope :published, default: true
index do
column :id
column :status
actions
end
end