<?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/"
	>

<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>Mon, 23 Jan 2012 15:44:09 +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><code class="ruby"><span class="keyword">def</span> index
  @poems = Poem.paginate<span class="symbol"> :page</span> =&gt; params<span class="symbol">[:page</span>],<span class="symbol"> <img src='http://www.sajithmr.me/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder</span> =&gt; <span class="string">'created_at DESC'</span>
<span class="keyword">end
</span></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>

