Case Insensitive Matching for PostgreSQL Like Query
Was that title a mouthful, or what!? Anyways, here is the problem I was trying to solve. I was wanting to write a query against my ActiveRecord model that finds an object where its email was like a search term. Well, here was my problem. Let's say my object's email was "[email protected]". If my search looked like this:Â
Then, if my search was "testuser", it isn't going to match anywhere with "[email protected]" because of the upper case 'T' and 'U'. So, what's a boy to do? Well, here is what I did.
Drop a little "LOWER" in front of the property I'm searching against, duh! Now, this will be searching "testuser" against "[email protected]" and will find said user. Hopefully this will be useful for someone else.















