Pagination - Next/Previous Linking problem

Hi all,

This is my controller function where am getting some collection of
objects using sql query.

def displaysearchlist
@userinformation_pages, @userinformations =
paginate(:userinformations, :conditions => “LoginName like ‘%#{var}
%’”, :order => “LoginName asc”, :per_page => 2)


In VIEW i want to display it with paging of 2 objects per page.

At first time it shows me the first page with correct entries.

But when i clicks on link ‘next’ or ‘previous’ it is shows me
entries from the table which are not related with the query. It shows
all the entries from the table as in List view.

view code is: -

Page: <%= @userinformation_pages.current.number %> <%= link_to 'Previous', { :page => @userinformation_pages.current.previous } if @userinformation_pages.current.previous %> <%= link_to 'Next ', { :page => } if %>

How to create paging for query related collections??

OR do i have create any session ??