Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case insensitive searching for words in mongoid

Is there a way to set an attribute in mongoid for case insensitive searches?

Lets say that somebody has a username: IAmGreat and I want to find the users data using their unique username without butchering it and changing it to iamgreat.

Thanks

like image 938
GTDev Avatar asked Sep 17 '11 16:09

GTDev


1 Answers

You can even try something like:

User.where(username: /#{username}/i).first
like image 126
mrudult Avatar answered Oct 22 '22 21:10

mrudult