Rails的分页现有的ActiveRecord的结果阵列 [英] Rails paginate existing array of ActiveRecord results
问题描述
我一般用will_paginate在我的应用程序分页,但打了stumbler在我的搜索功能。我使用的是狮身人面像的思考做我的全文搜索,返回的结果分页。我遇到的问题是,我从思考狮身人面像收到了效果后,我需要一些其他的结果和重新排序它们合并。
I generally use will_paginate for the pagination in my app, but have hit a stumbler on my search feature. I'm using Thinking Sphinx for doing my full-text search, which returns results paginated. The problem I'm having is that after I've received the results from Thinking Sphinx, I need to merge them with some other results and re-order them.
在我处理完他们,我有结果的数组,它是从TS原来有很大不同。由于可能有1000多个结果,在这阵分页是必要的。问题是,我无法弄清楚如何让will_paginate与现有阵列玩。
Once I've finished processing them I have an Array of results that is very different from the original from TS. As there could be 1000+ results in this Array Pagination is a necessity. The problem is that I can't figure out how to get will_paginate to play with an existing array.
我已经做了一些研究,它似乎是唯一的解决方案,这个问题是来自几年前,并根据各地老的内置分页程序类。最近的一次我能找到,使得使用will_paginate的是来自devchix从2007年年中:<一href="http://www.devchix.com/2007/07/23/will_paginate-array/comment-page-1/">http://www.devchix.com/2007/07/23/will_paginate-array/comment-page-1/ - 我给这个一展身手,但它似乎并没有对我做任何事
I've done some research and it seems the only solutions to this problem are from several years ago and are based around the old built-in Paginator class. The most recent one I could find that makes use of will_paginate was from devchix from mid-2007: http://www.devchix.com/2007/07/23/will_paginate-array/comment-page-1/ - I've given this a go but it doesn't seem to do anything for me.
是否有任何现有的方法为AR的结果现有阵列采用分页($ P $通过pferably will_paginate)?
Are there any current methods for applying pagination (preferably via will_paginate) for existing arrays of AR results?
推荐答案
在官方will_paginate维基链接到本,尽管从2008年:
The official will_paginate wiki links to this, albeit from 2008:
<一个href="http://www.pathf.com/blogs/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/">http://www.pathf.com/blogs/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/
这篇关于Rails的分页现有的ActiveRecord的结果阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!