user1275056
user1275056

Reputation:

How to save kaminari current page as a variable, for link use to go back to page left

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

Answers (2)

zisasign
zisasign

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

Purple Hexagon
Purple Hexagon

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

Related Questions