I have the acts_as_ferret plugin installed. Everything searches great,
but I would like to limit the results (i.e. by ‘end_date’) and sort them
(by ‘end_date’). ‘end_date’ is a valid column in my “posts” table.
Here’s the code I have already:
@posts = Post.find_by_contents(params[:query])
params[:query] comes from a form. I am replacing less efficent code that
has the restrictions working :
@posts = Post.find(:all,
:conditions => [ ‘(title LIKE :search_query OR body
LIKE :search_query) AND end_date >= :enddate’,
{:search_query => ‘%’ + params[:query] + ‘%’,
:enddate => Time.now}],
:order => ‘end_date’)
I realize i have to pass something similar to :conditions and :order,
but I can’t seem to get ferret to bey the options.
*Note: Whenever I tried to do this ferret would only sort the first page
of results. So if ferret returned 100 results and each page had 10 items
only the first 10 items would be sorted by the desired field. Of course
I was probably doing something wrong. Let me know how this works out for
you.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.