module ListController::Memory

Remembers certain params of the index action in order to return to the same list after an entry was viewed or edited. If the index is called with a param :returning, the remembered params will be re-used. Extracted into an own module for convenience.

Public Class Methods

included(controller) click to toggle source

Adds the :remember_params class attribute and a before filter to the index action.

# File lib/generators/dry_crud/templates/app/controllers/list_controller.rb, line 238
def self.included(controller)
  # Define a list of param keys that should be remembered for the list action.
  controller.class_attribute :remember_params
  controller.remember_params = [:q, :sort, :sort_dir, :page]

  controller.before_filter :handle_remember_params, :only => [:index]
end