Rails 3分页,will_paginate和Kaminari [英] Rails 3 pagination, will_paginate vs. Kaminari

查看:117
本文介绍了Rails 3分页,will_paginate和Kaminari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置:Rails 3.0.9,Ruby 1.9.2

My setup: Rails 3.0.9, Ruby 1.9.2

我正在研究我的应用程序的分页解决方案,发现与可信任的will_paginate相比,有一个新的宝石Kaminari.看来will_paginate暂时没有更新,但自V3.0起就回来了.共识是什么,一个比另一个更受青睐,为什么?预先感谢您的见解.

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.

编辑

我在Twitter上问了Ryan Bates,他说

I asked Ryan Bates on Twitter and he said

两者都做得很好.最大的因素是如果您使用任何 由于不兼容,需要分页的宝石.我喜欢 will_paginate的非引擎方法要多一些,但这是个人的 偏好.

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.

推荐答案

Kaminari rails 3+,我喜欢使用它,因为

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

  1. 这是最新的库,并且强大地支持rails 3 +.
  2. 'Kaminari'易于使用,并且非常容易支持ajax.
  3. 以纯分对象方式分页.
  4. 它在AREL上充当代理,ActiveRecord上没有重载特定的分页方法
  5. 不污染Array或Hash对象
  6. 对其他视图格式(最重要的移动设备

  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)

但是,如果您使用的是rails 2.3等,请坚持使用 will_paginate ,它也可以在rails 3 +上使用,但在内部,它不如Kaminari代码那么完美.

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.

这篇关于Rails 3分页,will_paginate和Kaminari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆