> I've noticed that typing "t" in the search box will return no results 
> however if I type "t*" it brings up all results beginning with t.
> 
> I would like this behaviour on by default without having to type the 
> wildcard. Is there a way to do this?

Add the following search method to your model

  def self.search(query)
    criteria = query.split
    wild_criteria = []
    criteria.each do |criterion|
      if criterion == "AND" || criterion == "OR"
        wild_criteria.push(criterion)
      else
        wild_criterion = "*"+criterion+"*"
        wild_criteria.push(wild_criterion)
      end
    end
    wild_criteria.pop if wild_criteria.last == "AND" || 
wild_criteria.last == "OR"
    wild_query = wild_criteria.join(" ")
    self.find_by_contents(wild_query)
  end

This also removes trailing logical operators, which will prevent it from 
screwing up a live search.

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to