Reputation: 5210
How can I disable pagination for json/xml export in activeadmin? I could't figure out any solution for this. I'm getting only current page when hitting export to xml or json.
Upvotes: 1
Views: 1774
Reputation: 1631
This can also be done like this,
controller do
def index
super do |format|
per_page = (request.format == 'text/html') ? 30 : 10_000 # to skip the pagination
params[:page] = nil unless (request.format == 'text/html') #It will be working even after we export the CSV on the paginated sections.
@users = @users.order("first_name asc, last_name asc").page(params[:page]).per(per_page)
@users ||= end_of_association_chain.paginate if @users.present?
end
end
end
Upvotes: 0
Reputation: 572
One solution (no the best) is disable de pagination with a before_filter
controller do
before_filter :disable_pagination, :only => [:index]
def disable_pagination
@per_page = YourModel.count
end
end
This make a pagination with only one page for all the records, so it is going to export all the records.
Upvotes: 2