Wednesday, February 25, 2009

Basically Pagination feature can done in no time using will_paginate plugin.Developers no need to worry about code development ,with this plugin two lines of code will give u pagination feature.
First we need to install the will_paginate plugin into application.
Following command will install plugin

>ruby script/plugin install svn://errtheblog.com/svn/plugins/will_paginate

Then need to add the pagination criteria ,i,e the number records to be displayed and name of the model etc..
For doing this follow this code

>@anyname=Modelname.paginate(:page => params[:page], :conditions =>["........'"],:per_page =>no_of_pages)

And then for viewing this pagination, we need to add following code in concerning .rhtml file

> <%= will_paginate @moment%>

This will allow to display pagination in rails application.