views:

29

answers:

2

Hi all

I have a model containing products. I would like to create a search form to allow users to apply compound filters to products as required. For example:

  • Products with a price of between '10' (text field) and '50' (text field) with a colour of 'Red', 'Green' or 'Blue' (check box fields) and a weight of 'Less than' (select field) '5kg' (text field).

There will be a considerable number of fields that a user can filter by -- some, all, or none of them may be specified.

I am aware that the above can be achieved by using named scopes, lots of conditional logic (case and if statements) and Rails form helpers, but is there a cleaner and more efficient way? Perhaps there is a gem/plugin to provide this functionality that I have overlooked?

Any advice much appreciated.

Many thanks.

+1  A: 

I recommend the plugin searchlogic:

nanda