zs2020
zs2020

Reputation: 54514

Mongomapper is referencing db using name causing ReferenceError issue

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.

Upvotes: 0

Views: 179

Answers (2)

zs2020
zs2020

Reputation: 54514

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

Upvotes: 0

Tyler Brock
Tyler Brock

Reputation: 30136

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)

Upvotes: 2

Related Questions