Blankman
Blankman

Reputation: 267200

Mongodb query says "wrong number of arguements (2 for 1)"

My query is dead simple, not sure what is going on:

User.rb

def self.find_house_number(house_number)
  User.where("house_number = ?", house_number)
end

So calling it:

User.find_house_number("9998883333")

I get the error:

wrong number of arguments (2 for 1)

Any ideas?

Upvotes: 1

Views: 632

Answers (1)

John Feminella
John Feminella

Reputation: 311645

#where takes a conditions hash, not a SQL-like string. You should do this instead:

User.where(:house_number => house_number)

Note that MongoDB has nothing to do with SQL, so you shouldn't assume that SQL fragments will work.

Upvotes: 3

Related Questions