Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Marcel's Profile

GitHub User: mwijnen

Comments by Marcel

Avatar

I ran into the problem with Mongoid that Mongodb stores the "id" as "_id":{"$oid":"524d74d31c187026b4000001"}. So not only the tag is different, also the id is nested.

What made it work for me is parsing the instance. See below.

class YourApp.Models.YourModel extends Backbone.Model

..parse: (your_model) ->
....your_model.id = your_model._id['$oid']
....your_model

(dots are white spaces)
This is important, because the "id" is needed to navigate to update instead of create, etc.

Hope this is helpful to anyone. If there is a better approach, Lmk. Coffee, JS and BB are new to me ;-)

Avatar

Dude! You rock! Thanks for the info.

Avatar

Thanks for mentioning that. It's useful even over a year later...