<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Programming Ideas, Logics, Tips and Tricks &#187; ruby</title>
	<atom:link href="http://www.sajithmr.me/category/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sajithmr.me</link>
	<description></description>
	<lastBuildDate>Sat, 07 Apr 2012 16:30:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Pagination in Ruby on Rails</title>
		<link>http://www.sajithmr.me/pagination-in-ruby-on-rails</link>
		<comments>http://www.sajithmr.me/pagination-in-ruby-on-rails#comments</comments>
		<pubDate>Sun, 02 Nov 2008 08:38:43 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[rail]]></category>

		<guid isPermaLink="false">http://www.sajithmr.com/?p=341</guid>
		<description><![CDATA[Old rails has a buitl in pagination option. For example is you have to paginate @user, which is a model object for the table user def user_list @user_pages,@users=paginate(:users,:order=&#62;&#8217;name&#8217;) end But in new version of rails, they removed the pagination option. So you need to install a plugin , which name is will_paginate You can install [...]]]></description>
			<content:encoded><![CDATA[<p>Old rails has a buitl in pagination option. For example is you have to paginate @user, which is a model object for the table user</p>
<p><strong>def user_list<br />
@user_pages,@users=paginate(:users,:order=&gt;&#8217;name&#8217;)<br />
end</strong></p>
<p>But in new version of rails, they removed the pagination option. So you need to install a plugin , which name is will_paginate</p>
<p>You can install this plugin using gem</p>
<p><strong>gem install will_paginate </strong></p>
<p>After the installation you have to add <strong>require &#8220;will_paginate&#8221; </strong>in config/environment.rb (at bottom)</p>
<p>You have to restart your ruby server after that.</p>
<p>In the controller area use:</p><pre class="crayon-plain-tag"><code>&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt; index
  @poems = Poem.paginate&lt;span class=&quot;symbol&quot;&gt; :page&lt;/span&gt; =&amp;gt; params&lt;span class=&quot;symbol&quot;&gt;[:page&lt;/span&gt;],&lt;span class=&quot;symbol&quot;&gt; :order&lt;/span&gt; =&amp;gt; &lt;span class=&quot;string&quot;&gt;'created_at DESC'&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;end
&lt;/span&gt;&lt;/code&gt;</code></pre><p>
and in the template page use</p>
<p><strong>&lt;%= will_paginate @poems, :container =&gt; false %&gt;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/pagination-in-ruby-on-rails/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

