Administrate: pagination gems

Created on 4 May 2018  路  6Comments  路  Source: thoughtbot/administrate

158 - referring the issues found there.

hi there

was hoping to make a PR to handle the issues noted in https://github.com/thoughtbot/administrate/issues/158

Here is what I thought might solve the solution.

   def paginate(resources)
      if resources.page(params[:page]).klass.respond_to?(:per)
        resources.page(params[:page]).per(records_per_page)
      elsif resources.page(params[:page]).klass.respond_to?(:paginate)
        resources.page(params[:page]).paginate(records_per_page)
      else        
        resources = resources.page(params[:page]).per(records_per_page) # what should go here?
      end
    end
  • Was wondering how to test this. Some people might use will_paginate, and others might use another gem. Still others might not paginate at all. was wondering how to test and handle this so i can make the right PR.
  • is this the appropriate way to handle dependencies which do not conform to a common interface?

some guidance / general direction much appreciated. i will be able to do the rest.

bug dependencies pagination

Most helpful comment

@nickcharlton Hi Nick, any pointers here? Some people might be using the new pagination gem: pagy - which might cause some issues with the above.

All 6 comments

Hi @BKSpurgeon!

Thanks for opening this and I'm sorry it's taken me a long time to look at it.

I'd suggest creating a new entry in Appraisals. You'll be able to add will_paginate there 鈥hat for sure looks like the commonest experience people have with a different pagination library.

Ok i'll have to have a look at that library. I'm not too familiar with it at this stage. hopefully i can get a successful PR to address this issue. chrs

@BKSpurgeon It's been a little while now. Is there anything I can help with?

Yes, I wasn't really sure what to do exactly.

All i need is a pointer in the right direction and i can do the rest :)

@nickcharlton Hi Nick, any pointers here? Some people might be using the new pagination gem: pagy - which might cause some issues with the above.

I'm going to close this, as it's been a while.

Administrate only supports using Kaminari so trying to use will_paginate will be quite difficult. Much like Pagy (see: #1441), it'd have to be quite compelling to switch to it, but there has been some discussion about abstracting the pagination handling so that you could slot your own in.

Was this page helpful?
0 / 5 - 0 ratings