-5

I need to perform this sql query in rails console (I'm using mongodb):

SELECT * FROM Member WHERE name='x' OR age='42'
Aboelseoud
  • 556
  • 1
  • 7
  • 22
  • What about reading some docs ? Or using google ? – cthulhu Mar 09 '13 at 09:39
  • Did that, didn't find anything useful. What about answering my question? – Aboelseoud Mar 09 '13 at 09:45
  • There are plenty of resources out there that show you how to do this. Official guides and SO-questions. If you haven't found anything, you clearly haven't been trying hard enough. Also - it is appreciated to show what solutions you have tried yourself already. – Jesper Mar 09 '13 at 12:15

2 Answers2

2

For Mongoid I use 'any_of'. This should work:

Member.any_of({:name => x, :age => 42})

Also here's a link to some other queries you can use with mongoid. I don't see these in their main doc page:

http://two.mongoid.org/docs/querying/criteria.html#any_of

ooHmartY
  • 66
  • 4
0

You should start by reading the Active Record Query Interface RailsGuide, it'll answer your question, and probably teach you some other things you don't already know.

DaveStephens
  • 1,126
  • 12
  • 16