Rails 4: simple wildcard search from console
This should do it:
word = 'emerging'
Product.where('title ILIKE ?', "%#{word}%")
- The ILIKE makes the search not sensitive to the case (PostgreSQL feature!)
- the "%" wildcard makes the search match every product having a title containing "word" inside with (or without) stuff before and/or after.
Use LIKE
, like this:
Product.where('title LIKE ?', '%emerging%')