Skip to content
mech edited this page Sep 14, 2010 · 10 revisions

How searching works!

Searching can be chained to Criteria#where and Criteria#in.

Job.where(:status => "open").search(:q => "engineer")

Examples of the resulting query

Company.where(:category => "=REGULAR").search(:q => "Benchmark") # Always expecting :q query

Query: (q0,q1);(q0,q2);(q0,q3)

Explain: q0 is :category and q1, q2 and q3 are all the searchable fields in Company model. This essentially means that q0 criteria need to appear in every searchable fields. You can find what searchable fields there are by calling Company.searchable_fields.

Clone this wiki locally