Fritz Trapper
2010-Nov-07 12:07 UTC
How to return to a particular page in a paginated index?
My scenario: I have a paginated index of records. The user clicks edit on a record in page 5. The edit form has different optional subforms, that return to the edit page. After committing the edit, show gets executed. Clicking ''back to index'' in show by default ends up in page 1 of the paginated index, instead of page 5. Is there some generic method, to pass the ''page=5'' parameter through all the intermediate forms to correctly build the link ''back to index'' as somthing like ''index?page=5'' ? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fritz Trapper
2010-Nov-09 00:20 UTC
Re: How to return to a particular page in a paginated index?
The solution is very simple: @records = Record.paginate( :page => params[:page] || session[:zb_page], # (2) :per_page => limit) session[:zb_page] = params[:page] if params[:page] # (1) + If a page was given, store it in the session cookie (1) + On paginateded find use the page given by params, or if not present that from the session cookie (2) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.