how to redirect to the "operating" page in will_paginate
Asked Answered
N

2

1

I have a message box using will_paginate. I have 6 messages showing in 3 pages, when i delete an item in page_3, it redirect_to page_1, how can i still be in page_3?!

Nervy answered 17/7, 2011 at 13:10 Comment(1)
You can start by showing us some code of how you implemented itNewmown
K
3

2 ways to solve the issue:

  1. "redirect_to :back"
  2. save params[:page] and redirect to the page once item is deleted
Kulun answered 17/7, 2011 at 14:46 Comment(0)
I
1

You can use method total_pages on instance variable which you are using for pagination.

example :
@user = User.find(params[:id])
@comments = @user.comments.paginate(:page => 1, :per_page => 20)
@comments.total_pages

@comment.total_pages will return you the last page no. which you can use for your redirection.

Insnare answered 8/7, 2013 at 7:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.