diff options
Diffstat (limited to 'vendor/plugins/will_paginate/README.rdoc')
| -rw-r--r-- | vendor/plugins/will_paginate/README.rdoc | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/vendor/plugins/will_paginate/README.rdoc b/vendor/plugins/will_paginate/README.rdoc deleted file mode 100644 index 2a412f5..0000000 --- a/vendor/plugins/will_paginate/README.rdoc +++ /dev/null | |||
| @@ -1,107 +0,0 @@ | |||
| 1 | = WillPaginate | ||
| 2 | |||
| 3 | Pagination is just limiting the number of records displayed. Why should you let | ||
| 4 | it get in your way while developing, then? This plugin makes magic happen. Did | ||
| 5 | you ever want to be able to do just this on a model: | ||
| 6 | |||
| 7 | Post.paginate :page => 1, :order => 'created_at DESC' | ||
| 8 | |||
| 9 | ... and then render the page links with a single view helper? Well, now you | ||
| 10 | can. | ||
| 11 | |||
| 12 | Some resources to get you started: | ||
| 13 | |||
| 14 | * {Installation instructions}[http://github.com/mislav/will_paginate/wikis/installation] | ||
| 15 | on {the wiki}[http://github.com/mislav/will_paginate/wikis] | ||
| 16 | * Your mind reels with questions? Join our | ||
| 17 | {Google group}[http://groups.google.com/group/will_paginate]. | ||
| 18 | * {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs] | ||
| 19 | |||
| 20 | |||
| 21 | == Example usage | ||
| 22 | |||
| 23 | Use a paginate finder in the controller: | ||
| 24 | |||
| 25 | @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC' | ||
| 26 | |||
| 27 | Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the | ||
| 28 | records. Don't forget to tell it which page you want, or it will complain! | ||
| 29 | Read more on WillPaginate::Finder::ClassMethods. | ||
| 30 | |||
| 31 | Render the posts in your view like you would normally do. When you need to render | ||
| 32 | pagination, just stick this in: | ||
| 33 | |||
| 34 | <%= will_paginate @posts %> | ||
| 35 | |||
| 36 | You're done. (You can find the option list at WillPaginate::ViewHelpers.) | ||
| 37 | |||
| 38 | How does it know how much items to fetch per page? It asks your model by calling | ||
| 39 | its <tt>per_page</tt> class method. You can define it like this: | ||
| 40 | |||
| 41 | class Post < ActiveRecord::Base | ||
| 42 | cattr_reader :per_page | ||
| 43 | @@per_page = 50 | ||
| 44 | end | ||
| 45 | |||
| 46 | ... or like this: | ||
| 47 | |||
| 48 | class Post < ActiveRecord::Base | ||
| 49 | def self.per_page | ||
| 50 | 50 | ||
| 51 | end | ||
| 52 | end | ||
| 53 | |||
| 54 | ... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default. | ||
| 55 | But you can always specify the count explicitly when calling +paginate+: | ||
| 56 | |||
| 57 | @posts = Post.paginate :page => params[:page], :per_page => 50 | ||
| 58 | |||
| 59 | The +paginate+ finder wraps the original finder and returns your resultset that now has | ||
| 60 | some new properties. You can use the collection as you would with any ActiveRecord | ||
| 61 | resultset. WillPaginate view helpers also need that object to be able to render pagination: | ||
| 62 | |||
| 63 | <ol> | ||
| 64 | <% for post in @posts -%> | ||
| 65 | <li>Render `post` in some nice way.</li> | ||
| 66 | <% end -%> | ||
| 67 | </ol> | ||
| 68 | |||
| 69 | <p>Now let's render us some pagination!</p> | ||
| 70 | <%= will_paginate @posts %> | ||
| 71 | |||
| 72 | More detailed documentation: | ||
| 73 | |||
| 74 | * WillPaginate::Finder::ClassMethods for pagination on your models; | ||
| 75 | * WillPaginate::ViewHelpers for your views. | ||
| 76 | |||
| 77 | |||
| 78 | == Authors and credits | ||
| 79 | |||
| 80 | Authors:: Mislav Marohnić, PJ Hyett | ||
| 81 | Original announcement:: http://errtheblog.com/post/929 | ||
| 82 | Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php | ||
| 83 | |||
| 84 | All these people helped making will_paginate what it is now with their code | ||
| 85 | contributions or just simply awesome ideas: | ||
| 86 | |||
| 87 | Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence | ||
| 88 | Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs | ||
| 89 | van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel, | ||
| 90 | Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein, | ||
| 91 | Denis Barushev, Ben Pickles. | ||
| 92 | |||
| 93 | |||
| 94 | == Usable pagination in the UI | ||
| 95 | |||
| 96 | There are some CSS styles to get you started in the "examples/" directory. They | ||
| 97 | are {showcased online here}[http://mislav.caboo.se/static/will_paginate/]. | ||
| 98 | |||
| 99 | More reading about pagination as design pattern: | ||
| 100 | |||
| 101 | * {Pagination 101}[http://kurafire.net/log/archive/2007/06/22/pagination-101] | ||
| 102 | * {Pagination gallery}[http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/] | ||
| 103 | * {Pagination on Yahoo Design Pattern Library}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination] | ||
| 104 | |||
| 105 | Want to discuss, request features, ask questions? Join the | ||
| 106 | {Google group}[http://groups.google.com/group/will_paginate]. | ||
| 107 | |||
