0
votes

I have a page in which I'd like to customize the entire default sql statement for the page. So unlike the example in the active admin docs here: https://activeadmin.info/2-resource-customization.html#customizing-resource-retrieval where they just add a condition, I'd like to be able to execute a custom sql statement. Is that possible?

the table that I'd like for to be displayed is modelled by the following SQL statement

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;

Any insight would be appreciated!

1
For pages there is not scoped_collection.zeitnot
what do you mean? Could you elaborate a little please?Ayudh

1 Answers

1
votes

Add this to the 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

But be aware of grouping, it works different on some databases.