跳过activeadmin索引方法中的一些特定记录
Skip some specific records in activeadmin index method
我只想在索引页上显示在 donation
登记的患者的唯一登记号。
我在患者 table 中有 on_donation
个字段。
ActiveAdmin.register Patient, as: 'Patient' do
belongs_to :physician
actions :index
menu false
index do
column :patient_uen do |row|
link_to(row.patient.uen, '#') if row.patient&.on_donation?
end
end
end
但是对于未接受捐赠的患者,这显示了空行。
有没有办法将 if-condition
或类似的东西放在 index do 中,这样它就不会显示空行。
将以下 controller
添加到 ActiveAdmin
class 之前 index
方法
controller do
def scoped_collection
super.where(on_donation: true)
end
end
我只想在索引页上显示在 donation
登记的患者的唯一登记号。
我在患者 table 中有 on_donation
个字段。
ActiveAdmin.register Patient, as: 'Patient' do
belongs_to :physician
actions :index
menu false
index do
column :patient_uen do |row|
link_to(row.patient.uen, '#') if row.patient&.on_donation?
end
end
end
但是对于未接受捐赠的患者,这显示了空行。
有没有办法将 if-condition
或类似的东西放在 index do 中,这样它就不会显示空行。
将以下 controller
添加到 ActiveAdmin
class 之前 index
方法
controller do
def scoped_collection
super.where(on_donation: true)
end
end