If you don't want sorting applied always, then I'd recommend something like
this:
search_options = {}
if params[:order] && %w(first_name last_name country).include?(params[:order])
search_options[:order] = params[:order].to_sym
end
Model.search params[:query], search_options
Cheers
--
Pat
On 06/03/2012, at 6:43 AM, dmc wrote:
> Right now I am currently displaying search results by relevance and
> there is no sorting going on beyond that. I was wondering I would go
> about making it so people can order the results by a certain column.
>
> I already have the column set as :sortable => true, and when I hard-
> code ":order => :column" it works fine. However, I do not want it hard-
> coded and would prefer it as an optional option that is just enabled
> via a link on the results page.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.