• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

The PaginationScope library is a pagination library of the NamedScope era.

The difference to the last version is only a small bug fix. So you can keep using it if you don't mind.

That's all. But I shall use this opportunity to write some document for the helper method of the library.

SYNOPSIS:

   1  paginate <scope>[, <options>]

The scope is a pagination scope object. The options is a hash including several parameters as follows.

  • :newer The label string for the link to a newer page.
  • :older The label string for the link to an older page.
  • :left The number of pages which appears on the left side.
  • :right The number of pages which appears on the right side.
  • :window The width of pages which surrounds the current page.
posted by Png takiuchi on Wed 20 Aug 2008 at 02:34

I made a new pagination library for the NamedScope era. You can use will_paginate for ordinary case. It must be better than the young PaginationScope library. But if you want to paginate with complicated chained named_scopes, this is suitable.

Usage

At first, include the module into your model class.

   1  class Post
   2    include PaginationScope

By this, the scope named "paginate" is made.

And then, in the controller of which you want to use pagination, you can get the scope for pagination like this.

   1  class PostsController < ApplicationController
   2    def index
   3      @posts = Post.not_deleted.paginate(params[:page], 10)

Finally, the pagination links are generated by calling the view helper, like this.

   1  <%= paginate @posts %>

Have fun!

posted by Png takiuchi on Sat 16 Aug 2008 at 23:58
Contents
Shipped the PaginationScope-0.0.3
PaginationScope: The Pagination Library of the NamedScope Era
Comments
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
falsefalse: @tiancongxin try using this one https://github.... '12-2
tiancongxin: TerminalCopyOnSelect not work on OS X 'Lion' , ... '11-7
staiano: Roderick you rock for recompiling it. Thanks. '11-3
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ