Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

Rails 3 pagination, will_paginate vs. Kaminari

My setup: Rails 3.0.9, Ruby 1.9.2

I'm looking into a pagination solution for my app and saw that there is a new-ish gem Kaminari compared to the trusty will_paginate. It looks like will_paginate wasn't updated for awhile but has since came back with V3.0. What's the consensus, is one preferred over the other and why? Thanks in advance for your insights.

EDIT

I asked Ryan Bates on Twitter and he said

Both do the job equally well. The biggest factor is if you use any gems which require pagination since they are incompatible. I do like will_paginate's non-engine approach a bit more, but that's a personal preference.

question from:https://stackoverflow.com/questions/8186985/rails-3-pagination-will-paginate-vs-kaminari

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Kaminari Rocks if you are using rails 3+ , I like to use it because

  1. It is latest library and supports rails 3+ powerfully.
  2. 'Kaminari' is Easy to use and it supports ajax very easily.
  3. Paginate pure Object way.
  4. It works as a proxy on AREL, no specific paginate method overloaded on ActiveRecord
  5. Does not pollute the Array or Hash object
  6. More standard rails support for other view formats, most important mobile

    User.page(7).per(50)
    

    But if you are using rails 2.3 etc. keep stick with will_paginate that also works with rails 3 +, but internally its not such perfect as Kaminari code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...