Double filter plugin

Plugin details

`Double Filter' is very useful plugin when you want to add a filtering feature.
`Double Filter' assumes that you want to filter by two columns and the two columns are independent of each other.

Repositoryhttp://opensvn.csie.org/double_filter/trunk/ Tags filter, controller LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install http://opensvn.csie.org/double_filter/trunk/

Usage
==================
0. Prepare your controller to add `Double Filter' feature `Double Filter' needs some controller to apply.
In this example, we assume the name of controller is `FooController' and is defined in `foo_controller.rb'.
1. Write configuration file , config/double_filter.yml
Configuration file is somethin like below:

 foo:                     # controller name
   model: Foo             # model name
   column0: bar_column    # db column name
   abbrev0: bar           # element id and rhtml filename
   column1: baz_column
   abbrev1: baz
   recordset: foos   # name of the array of ActiveRecord in your list.rhtml,
   pages: foo_pages  # name of pagination object in your list.rhtml


2. Generation of double filter views

 > ruby script/generate double_filter_view foo
 create app/views/foo/_double_filter.rhtml
 create app/views/foo/filtered_list.rhtml


3. Edit a controller file

In you `app/controllers/foo_controller.rb'

 class FooController
   include DoubleFilter
   double_filter "foo"   # the controller name defined in double_filter.yml
   ...
 end


4. Add some lines into existing files.
In your `index.rhtml' , `list.rhtml' or `_list.rhtml'

 <%= render_partial "double_filter" %>


In the corresponding controller method, please invoke `collect_column_information' method.
example:

If your `list.rhtml' has partial rendering of`Double Filter' `list' method of your controller needs to invoke collect_column_information

 def list
   collect_column_information
   ...
 end


5. Edit `_double_filter.rhtml' and `filtered_list.rhtml' as you like.

6. Have Fun.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago