Topic: Question about paginate

I'm having a problem using paginate on a simple query so i thought i'd see if anyone could help me out.

This seems very simple on the surface, not sure what i'm doing wrong.  In my controller, i have the following method defined:
  def list
    @phase_tracking_pages, @phase_trackings = paginate(:phase_trackings, :conditions => ["req_id = ?", params[:req_id]], :per_page => 10)

Then in my view, i have the following:
<%= link_to 'Previous page', { :page => @phase_tracking_pages.current.previous } if @phase_tracking_pages.current.previous %>
<%= link_to 'Next page', { :page => } if %>

For the first page, everything works fine, i get the data i'm expecting and it displays correctly.  However, when i click on next, it does not display any data, even though i know there are additional rows there.  Do you see anything i'm doing wrong?


Re: Question about paginate

Try passing the req_id parameter in the link:

<%= link_to 'Previous page', { :page => @phase_tracking_pages.current.previous, :req_id => params[:req_id] } if @phase_tracking_pages.current.previous %>
<%= link_to 'Next page', { :page =>, :req_id => params[:req_id] } if %

Railscasts - Free Ruby on Rails Screencasts

Re: Question about paginate