randym / activeadmin-axlsx

ActiveAdmin plugin using Axlsx for adding Excel (xlsx) download links for your resources
MIT License
82 stars 134 forks source link

Export all records without pagination #11

Closed tommyalvarez closed 11 years ago

tommyalvarez commented 11 years ago

Hi! I couldn't find it anywhere, is there a way to export all records without pagination getting involved? E.g. I'm in the active admin index view of Users and when i export as xlsx only the current page is exported. How can i export ALL records?

th1988 commented 11 years ago

I solved it with overwriting the collection method like this:

  controller do

    protected

    def collection
      if params[:format].eql?("xlsx")
        @users ||= User.all
      else
        @users ||= User.page(params[:page]).per(50)
      end 

    end 
  end
randym commented 11 years ago

hi @tommyalvarez

What @th1988 posted is exactly what you need to do. activeadmin-axlsx does not, and should not have any control over what the collection contains.