Ruby on Rails - activerecord case insensitive search in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
- If we need to search an ActiveRecord model for similar values, we might be tempted to use LIKE or ILIKE but this isn't portable between database engines.
- Similarly, resorting to always downcasing or upcasing can create performance issues.
Example
We can use ActiveRecord's underlying Arel matches method to do this in a safe way:
Arel will apply the appropriate LIKE or ILIKE construct for the database engine configured.