Mongomapper is referencing db using name causing ReferenceError issue

188 Views Asked by At

This is the query generated by Mongomapper:

MONGODB mydatabase['users'].find({:name=>"bob"}).limit(-1)

But this is not valid in the mongo console since the correct syntax is

db.users.find({:name=>"bob"}).limit(-1)

If I just use the generated one, I got this error in the console

Thu Jan 12 03:01:23 ReferenceError: mydatabase is not defined (shell):1

Is there any way to make it correct? This causes my rails application broken.

2

There are 2 best solutions below

0
On BEST ANSWER

It is not mongodb's issue. 406 is pretty much relating to the controller call.

I need to use:

render :json => @user

rather than

respond_to
2
On

You can't use symbols in the MongoDB console as they are ruby and not javascript :-) Try this:

db.users.find({name: "bob"}).limit(-1)