Skip to content

MetaSearch fun

by nick on March 29th, 2012

I needed to search for multiple values across multiple fields in a search.

params[:search_like] = 'Fanuc 15'
@search_params['make_or_model_in'] = params[:search_like].split(' ')
Machine.search(@search_params)

Results in:

SELECT COUNT(*) FROM machines WHERE ((machines.make IN ('fanuc', '15') OR machines.model IN ('fanuc', '15')))

Related Posts

  • No Related Post

From → General

Comments are closed.