0.0
No release in over 3 years
Low commit activity in last 3 years
Makes it easy to return to exact position on index pages after clicking on records.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.8

Runtime

~> 5.0
 Project Readme

RememberParams

Rails gem that makes actions remember GET params like keywords and page.

Scenario

Say you have that index action where you can search, filter and paginate through records. Once you click on one of the records you lose track of the exact location (e.g. search keywords, filter settings or page).

RememberParams will bring users back to that exact location when they return to the index page by remembering the search keywords, filter settings and page.

Usage

To make a controller action remember its params simply add the remember_params line on top like this:

class BooksController < ApplicationController
  remember_params :keywords, :page # defaults are on: index and duration: 1.hour
  remember_params :client_id, on: :client_list, duration: 1.minute
end

Browsing the action without any params will automatically try to restore params and redirect to the same route but with previously set params.

If for example you have the keywords params remembered and follow a link with only a page param, the remembered keywords param and the newly set page param will be mixed.

Reset all remembered params like this:

link_to 'Books', books_path(reset_params: true)

You can also mix reset_params and setting new params.

link_to 'Books', books_path(reset_params: true, page: 2)

Installation

Add this line to your application's Gemfile:

gem 'remember_params'

And then execute:

$ bundle

Or install it yourself as:

$ gem install remember_params

License

The gem is available as open source under the terms of the MIT License.