Rails 3 pagination, will_paginate vs. Kaminari

前端 未结 5 723
轮回少年
轮回少年 2021-02-03 18:36

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

相关标签:
5条回答
  • 2021-02-03 18:47

    I have used both Gems, and frankly, I like Kaminari better. It's so easy to use. I haven't seen any performance issues or environment issues (my app lives on Heroku).

    0 讨论(0)
  • 2021-02-03 18:49

    While will_paginate does the job pretty quickly, Kaminari also allow you to quickly edit the pagination HTML output.

    This was a great thing for me, since i am using Bootstrap 3, and wanted to use the default paginations styles.

    There is a gem for will_paginate that allows you to do the same, but Kaminari it's much more flixible

    0 讨论(0)
  • 2021-02-03 18:54

    I really like Kaminari. I don't know if will_paginate does this, but Kaminari also can paginate any regular old Array:

    Kaminari.paginate_array(an_array).page params[:page]
    

    There are Railscasts for both, which I recommend watching.

    0 讨论(0)
  • 2021-02-03 19:04

    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.

    0 讨论(0)
  • 2021-02-03 19:07

    watch the kaminari railscast an then watch the will paginate railscast

    Ryan Bates advises in the comments that Kaminari makes heavier use of partials, which might make it fractionally slower, but not much

    0 讨论(0)
提交回复
热议问题