Reputation: 9693
I'm using active_admin for one of my projects, and I have some tables with a lot of data (+100,000 records).
Its fine to paginete to browse the data, but when I want to export the data (so I can do custom match in excel), and I try to export in xml, it just export the current records of the page, instead of exporting the total records on the filtering.
module ActiveAdmin
class ResourceController
module Collection
module Pagination
def max_csv_records
1_000_000
end
end
end
end
end
but that won't work for xml/json, any ideas how to solve that?
Thx
Upvotes: 0
Views: 1582
Reputation: 2918
This might help for some versions of active admin:
module ActiveAdmin::ResourceController::DataAccess
protected
def apply_pagination_with_csv(chain)
return chain if request.format == 'text/csv'
apply_pagination_without_csv(chain)
end
alias_method_chain :apply_pagination, :csv
end
To figure out if the patch works you should pick into the installed gem this file
Upvotes: 1
Reputation: 9693
I ended up doing another monkey patch, there may be a better way but this one works
module ActiveAdmin
class ResourceController
module Collection
module Pagination
def per_page
return 1_000_000 if %w(text/csv application/xml application/json).include?(request.format)
return max_per_page if active_admin_config.paginate == false
@per_page || active_admin_config.per_page
end
end
end
end
endend
Upvotes: 1