Show and Back

Wondering if I can get some feedback as to the best approach to handling
the following issue:

  • you have 300 items and pagination is set to 10 items per page
  • you are on page 10 and call the show action
  • you then click back and it calls list on the controller
  • the pagination starts again on page 1

Are people use hidden form fields, then passing the page number to the
show, edit actions?

What’s the best way to handle this?

Thanks for any advice.

JD

Are people use hidden form fields, then passing the page number to the
show, edit actions?

Why not save the page variable in a session?

Beate

Beate P. wrote:

Are people use hidden form fields, then passing the page number to the
show, edit actions?

Why not save the page variable in a session?

Beate

Ended up taking this approach:

In list.rhtml, add a page_number parameter to the show action link:

<%= link_to ‘Show’, :action => ‘show’, :id => media, :page_number
=>@media_pages.current %>

In show action on the controller, grab that parameter into a variable so
you can access it from show.rhtml view:

@page_number = params[:page_number]

In show.rhtml view, pass the list action on the controller the page
number:

<%= link_to ‘Back’, :action => ‘list’, :page => @page_number %>

Seems to work well. I wonder if there is an easier or more elegant way
to do this?