I\'m trying to find all documents whose text contains the word test. The below works fine:
@tweets = Tweet.any_of({ :text => /.*test.*/ })
H
There is nothing wrong with the mongodb regex query. The problem is passing variable to ruby regex string. You cannot mix string with regex like normal strings
Instead
"/.*"+searchterm+".*/"
try this
>>searchterm = "test" >>"/#{searchterm}/" >> "/test/"