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?!
how to redirect to the "operating" page in will_paginate
Asked Answered
You can start by showing us some code of how you implemented it –
Newmown
2 ways to solve the issue:
- "redirect_to :back"
- save params[:page] and redirect to the page once item is deleted
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.
© 2022 - 2024 — McMap. All rights reserved.