Best way to implement simple sort / search in Rails
What's the best way to implement an interface that looks like this in rails?

I am currently using Searchlogic and it is a little painful. Problems include:
-
Make sure certain operations remain orthogonal - for example, if you select "Short Messages" and then search, your search results should be limited to short messages.
-
Make sure the correct link is getting the "selected" class. There are links right now
<a>
, so keeping this client-side state is tricky. I hack it by responding to an AJAX request, say sort, returning a new section of sorting links with the correct "selected" link. Using radio buttons instead of tags<a>
would make it easier to persist state on the client side - maybe I should?
a source to share
I recently solved the problem using named_scopes and some ruby metaprogramming which I rolled into a plugin called find_by_filter .
find_by_filter takes a hash of the scope of names and values, and associates them with calls to the parameterized scope. If the model has a named_scope that matches the supplied name, it is called. If the named_scope name is not found, an anonymous scope is created.
a source to share