Created
February 26, 2012 01:28
-
-
Save miligraf/1912066 to your computer and use it in GitHub Desktop.
Mongoid version of SQL "SELECT * FROM Objects WHERE field1 LIKE '%search%' OR field2 LIKE '%search%'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
search = params[:search][:text] | |
results = Object.any_of({ field1: /#{search}/ } , { field2: /#{search}/ }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remember that MongoDB is case sensitive!