I have some problem with this mongoid. It’s my first time to use mongoDB, Before, I always use mySQL.
Here is my problem.
I have model “User”. In model “User” has embedded one “Profile”,
and I want to search users data with criteria name “dummy” for field “profile.first_name”,
“profile.last_name”, and “username”.
I already use this syntax, but I got empty result:
@filter = "dummy"
@users = User.any_of({'profile.first_name' => /#{@filter}/i, 'profile.last_name' => /#{@filter}/i, :username => /#{@filter}/i})
Try this
look at the brackets.