我有一个页面,我想在其中自定义页面的整个默认SQL语句。因此,与Active Admin文档中的示例不同:https://activeadmin.info/2-Resource-customization.html#customizing-resource-retrereval他们只是添加条件,我想能够执行自定义SQL语句。这可能吗?
我想显示的表由以下SQL语句
建模select driver_id, order_type_cd, start_region, ARRAY_AGG(region_id) from driver_region_preferences group by driver_id, order_type_cd, start_region;
任何见解都将不胜感激!
将其添加到admin/driver_region_preference.rb
controller do
def scoped_collection
end_of_association_chain.select('driver_id, order_type_cd, start_region, ARRAY_AGG(region_id)').group('driver_id, order_type_cd, start_region')
end
end
但要注意分组,它在某些数据库中起作用。