{"id":7530,"date":"2015-07-26T05:10:53","date_gmt":"2015-07-26T05:10:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/07\/26\/mislav-will_paginate\/"},"modified":"2015-07-26T05:10:53","modified_gmt":"2015-07-26T05:10:53","slug":"mislav-will_paginate","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/07\/26\/mislav-will_paginate\/","title":{"rendered":"mislav\/will_paginate"},"content":{"rendered":"<p>will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Merb, DataMapper and Sequel.<\/p>\n<p>Installation:<\/p>\n<pre><code>## Gemfile for Rails 3+, Sinatra, and Merb\ngem 'will_paginate', '~&gt; 3.0.6'\n<\/code><\/pre>\n<p>See installation instructions on the wiki for more info.<\/p>\n<h2>Basic will_paginate use<\/h2>\n<pre><code>## perform a paginated query:\n@posts = Post.paginate(:page =&gt; params[:page])\n\n# or, use an explicit \"per page\" limit:\nPost.paginate(:page =&gt; params[:page], :per_page =&gt; 30)\n\n## render page links in the view:\n\n<\/code><\/pre>\n<p>And that\u2019s it! You\u2019re done. You just need to add some CSS styles to make those pagination links prettier.<\/p>\n<p>You can customize the default \u201cper_page\u201d value:<\/p>\n<pre><code># for the Post model\nclass Post\n  self.per_page = 10\nend\n\n# set per_page globally\nWillPaginate.per_page = 10\n<\/code><\/pre>\n<p>New in Active Record 3:<\/p>\n<pre><code># paginate in Active Record now returns a Relation\nPost.where(:published =&gt; true).paginate(:page =&gt; params[:page]).order('id DESC')\n\n# the new, shorter page() method\nPost.page(params[:page]).order('created_at DESC')\n<\/code><\/pre>\n<p>See the wiki for more documentation. Ask on the group if you have usage questions. Report bugs on GitHub.<\/p>\n<p>Happy paginating.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>will_paginate is a pagination library that integrates with Ruby on Rails, Sinatra, Merb, DataMapper and Sequel. Installation: ## Gemfile for Rails 3+, Sinatra, and Merb gem &#8216;will_paginate&#8217;, &#8216;~&gt; 3.0.6&#8217; See installation instructions on the wiki for more info. Basic will_paginate use ## perform a paginated query: @posts = Post.paginate(:page =&gt; params[:page]) # or, use an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7530","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7530"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7530\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}