Sha256: a87d2085a7da918209583b8c82c3ff2aeb89324d1a6d3a2d18e8fe647af66942

Contents?: true

Size: 1.51 KB

Versions: 29

Compression:

Stored size: 1.51 KB

Contents

CONTROLLER
==========

There are two methods you use in a controller:
* filterrific_init to initialize the Filterrific object. It is stored in the @filterrific ivar. This
  method first initializes the filter params:
  params[param_name] || session[session_key] || Model.filterrific_defaults
  Then it persists the filter_params in the session, using session_key.
* Model.filterrific_find to populate your ActiveRecord collection based on filterrific params.
  filterrific_find is a composable ActiveRecord relation. That means you can chain it with other
  relations like scopes, pagination, etc.

Example controller code:

def index
  @filterrific = filterrific_init(Publication, options={})
  Options:
  * :persist_in_session => true OR "publications_list"  # if true, builds session_key from
    controller-action
  * :debug => false  # if true, prints out debug info. This also exists in view helper. Maybe one to
    logger/STDOUT, the other to view?
  * :param_prefix => "filterrific"  # the param prefix used to shuttle params between view and controller.

  @publications = Publication.filterrific_find(@filterrific).paginate....
  @publications = current_user.publications.filterrific_find(@filterrific).paginate....
  ...
end

@filterrific = Filterrific.new(User, params_hash)
@users = User.filterrific_find(@filterrific).where(...)

@filterrific = Filterrific.new(self, User)
@filterrific = filterrific_init(User, options) (loads and persists in session)
@users = User.filterrific_find(@filterrific).paginate(:page => params[:page])

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
filterrific-5.2.5 doc/development_notes/controller_api.txt
filterrific-5.2.4 doc/development_notes/controller_api.txt
filterrific-5.2.3 doc/development_notes/controller_api.txt
filterrific-5.2.2 doc/development_notes/controller_api.txt
filterrific-5.2.1 doc/development_notes/controller_api.txt
filterrific-5.2.0 doc/development_notes/controller_api.txt
filterrific-5.1.0 doc/development_notes/controller_api.txt
filterrific-4.0.1 doc/development_notes/controller_api.txt
filterrific-5.0.1 doc/development_notes/controller_api.txt
filterrific-5.0.0 doc/development_notes/controller_api.txt
filterrific-3.0.0 doc/development_notes/controller_api.txt
filterrific-4.0.0 doc/development_notes/controller_api.txt
filterrific-2.1.2 doc/development_notes/controller_api.txt
filterrific-2.1.1 doc/development_notes/controller_api.txt
filterrific-2.1.0 doc/development_notes/controller_api.txt
filterrific-2.0.5 doc/development_notes/controller_api.txt
filterrific-2.0.4 doc/development_notes/controller_api.txt
filterrific-2.0.3 doc/development_notes/controller_api.txt
filterrific-2.0.2 doc/development_notes/controller_api.txt
filterrific-2.0.1 doc/development_notes/controller_api.txt