浏览 2441 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2007-02-05 关键字: Rails
def paginate_collection(collection, options = {})
default_options = {:per_page => 10, :page => 1} options = default_options.merge options pages = Paginator.new self, collection.size, options[:per_page], options[:page] first = pages.current.offset last = [first + options[:per_page], collection.size].min slice = collection[first...last] return [pages, slice] end The above snippet can be invoked using @pages, @users = paginate_collection User.find_custom_query, :page => @params[:page] 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2007-02-05
如果能有一个完整的例子就好了
|
|
| 返回顶楼 | |
|
最后更新时间:2007-02-05
def list_for_one_category
@category = Category.find(params[:id]) @article_pages, @articles = paginate_collection @category.articles, :per_page => 10 end |
|
| 返回顶楼 | |
|
最后更新时间:2007-02-06
我以前有花點時間寫這個東西
Maybe helpful http://lightyror.thegiive.net/2006/11/pagination-collection.html |
|
| 返回顶楼 | |





