Forum: Ruby on Rails Pagination - Next/Previous Linking problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
manohar amrutkar (Guest)
on 2007-02-07 12:57
(Received via mailing list)
Hi all,

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

def displaysearchlist
    var=params[:txtsearch]
    @userinformation_pages, @userinformations =
paginate(:userinformations, :conditions  => "LoginName like '%#{var}
%'", :order => "LoginName asc", :per_page => 2)

end


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: -

<table height="10" width="100%" border="0">
<tr>
<td align="left" width="100%" class="generallink">Page: <%=
@userinformation_pages.current.number %>&nbsp;<%= link_to 'Previous',
{ :page => @userinformation_pages.current.previous } if
@userinformation_pages.current.previous %>
<%= link_to 'Next ', { :page => @userinformation_pages.current.next }
if @userinformation_pages.current.next %> </td>
</tr>
</table>

How to create paging for query related collections??

OR do i have create any session ??
This topic is locked and can not be replied to.