On 06 Dec 2011, at 17:14, Kausik Bakshi wrote:
> I use mongoid for rails application
> and I try to do
> @users = User.where("first_name = ? OR last_name = ? OR type =
?",
> firstname, lastname, usertype)
>
> but I am getting error
> but when i put:
> @users = User.where(:first_name => firstname, :last_name => lastname,
> :type => usertype).all
>
> the program run successfully
> but i need OR to execute in mongodb
> Also I need sql LIKE to execute in mongodb
>
> I have learned the raw code of mongodb
> but I need a help for Rails query
Reading the documentation usually helps:
http://mongoid.org/docs/querying/criteria.html
Especially the "Model.any_of | Criteria#any_of" section seems to cover
your case.
Best regards
Peter De Berdt
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.