ruby-on-railssearchsortingsearchlogic

Best way to implement simple sorting / searching in Rails


What's the best way to implement an interface that looks like this in rails?

interface example

Currently I'm using Searchlogic, and it's a tad painful. Problems include:


Solution

  • I recently solved a similar problem using named_scopes and some ruby metaprogramming that I rolled up into a plugin called find_by_filter.

    find_by_filter accepts a hash of scope names and values, and chains them into parametised scope calls. If the model has a named_scope that matches the provided name, this is called.If no named_scope is found, an anonymous scope is created.