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)
  end

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 => @phase_tracking_pages.current.next } if @phase_tracking_pages.current.next %>

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?

Thanks,
Tom

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 => @phase_tracking_pages.current.next, :req_id => params[:req_id] } if @phase_tracking_pages.current.next %

Railscasts - Free Ruby on Rails Screencasts

Re: Question about paginate

excellent...Thanks!