Skip to content
Newer
Older
100644 51 lines (34 sloc) 1.23 KB
ae6f5fc @mislav new Readme
authored Jul 28, 2011
1 # will_paginate
2
3 A pagination library for Rails, DataMapper and Sequel.
4
5 Installation:
6
7 ``` ruby
8 ## Rails 3: Gemfile
9 gem 'will_paginate', '~> 3.0.pre4'
10
11 ## Rails 2.1 - 2.3: environment.rb
12 Rails::Initializer.run do |config|
13 config.gem 'will_paginate', :version => '~> 2.3.15'
14 end
15 ```
16
17 See [installation instructions][install] on the wiki for more info.
18
19 Basic use:
20
21 ``` ruby
22 # controller: perform a query
23 @posts = Post.paginate(:page => params[:page], :per_page => 30)
24
25 # view: render page links
26 <%= will_paginate @posts %>
27 ```
28
29 That's it!
30
31 New Rails 3 features:
32
33 ``` ruby
34 # paginate in ActiveRecord now returns a Relation
35 Post.where(:published => true).paginate(:page => params[:page]).order('id DESC')
36
37 # new, shorter page method
38 Post.page(params[:page])
39
40 # new global per_page setting
41 WillPaginate.per_page = 10
42 ```
43
44 See [the wiki][wiki] for more documentation. [Ask on the group][group] if you have usage questions. [Report bugs][issues] on GitHub.
45
46
47 [wiki]: https://github.com/mislav/will_paginate/wiki
48 [install]: https://github.com/mislav/will_paginate/wiki/Installation "will_paginate installation"
49 [group]: http://groups.google.com/group/will_paginate "will_paginate discussion and support group"
50 [issues]: https://github.com/mislav/will_paginate/issues
Something went wrong with that request. Please try again.