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 userlist
@user
pages,@users=paginate(:users,:order=>’name’)
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 this plugin using gem

*gem install will_paginate *

After the installation you have to add *require “will_paginate” *in config/environment.rb (at bottom)

You have to restart your ruby server after that.

In the controller area use:

<code class="ruby"><span class="keyword">def</span> index
@poems = Poem.paginate<span class="symbol"> :page</span> => params<span class="symbol">[:page</span>],<span class="symbol"> :order</span> => <span class="string">'created_at DESC'</span><span class="keyword">end </span>

and in the template page use

<%= will_paginate @poems, :container => false %>