Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Sample app with pagination, search and sort params persisted between pages

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.markdown

Sample app with pagination, search and sort params persisted between pages

This is a very basic rails 3 app for showing a way to persist params between each requests through sessions. For this sample I use the both fantastics kaminari and meta search

running it:

bundle

rake db:migrate

rails s

all happens in application controller:

before_filter :persist_params, :only => :index
def persisted_params
  (self.class.to_s + "_persisted").to_sym
end

def persist_params
  session[persisted_params] ||= {} 
  [:page, :search].each do |k|
    if params[k] then
      session[persisted_params][k] = params[k]
    elsif session[persisted_params][k]
      params[k] = session[persisted_params][k]
    end
  end
end

and something I've monkeypatched in kaminari for passing params page=1 for the first page

Something went wrong with that request. Please try again.