Reputation:
I'm using the kaminari pagination ruby on rails gem. Each entry I'm pulling has a edit link, which takes user to another page where they can edit. Currently, with :back set for the href value in my link back it always goes to page one.
I'm trying to save the url variable for the page when it clicks, and then set the back link to that variable.
Upvotes: 2
Views: 2006
Reputation: 83
I add it to cookies, like cookies[:current_page]
.
And in a show view(or some other action page), add a params to link that redirect to index action page like articles_path(grid:{page:cookies[:current_page]})
It's not the best way, but it does the trick.
Upvotes: 0
Reputation: 3578
You could use javascript to access the browser history and do
onclick="window.history.back();"
or you could add the variable to your href on the paginated view like.
<%= link_to "mymodel", model_path(:prevpage => params[:page]) %>
Upvotes: 1