I have a simple form, where I set up a query that I want to browse, for example panasonic viera. This is on how I search the term in database:
Product.where("name ilike ?", "%#{params[:q]}%").order('price')
The query looks like %panasonic viera%, but I would need to search the query this way: %panasonic%viera% - I need to find all products, where is in the title the word panasonic or viera... but how to make this query?
If you're using PostgreSQL, you can use
pg_search
gem. It's support full text search, with optionany_word
:Example from
pg_search
:One solution would be to break up your query into individual terms and build a set of database queries connected by
OR
.How about via ARel
This isn't working?