Let's suppose I have a search box that searches through the 'Person'
model, that has the 'full_name' and 'address' attributes.
In the 'Person' controller, there's a 'search' method, that takes the
query (as params[:query]) from the view:
@search = Person.search params[:query]
After filling the '@search' variable, the 'search' method renders the
'show' action. So far so good.
What I want, is that I have 'sort by' links in my views, like 'Sort by
name' and 'Sort by address'.
I wanted to do a method, to order like this: @search.sort_by(:field).
I think that is the cleanest way of doing this.
What do you guys think?