mongo_mapper or mongoid with rails4
Asked Answered
S

1

10

The ORM mongo_mapper and mongoid both support ruby on rails. However, after reading their documents I still cannot make a decision which one to use to develop a new application with rails4.

Any suggestion?

Spiceberry answered 9/12, 2013 at 13:46 Comment(2)
https://mcmap.net/q/257607/-mongoid-or-mongomapper-closedReverse
It was answered in rails3 age. So do they still apply to rails4?Spiceberry
B
11

I have used MongoMapper but decided to migrate to MongoId. both of them are great MongoDB Libraries for Ruby, but after reading a lot about the difference, I ended up using mongoid because of this.

You can find some differences between those MongoDB Libraries here, and decide which of them is more suitable to your requirments:

Baculiform answered 9/12, 2013 at 14:4 Comment(12)
did you have any issues switching? we're thinking about switching too and would love any advice.Diskin
Yes,sure.. Do you want me to send you a document, with all the issues switching?Baculiform
we ran into a "TypeError: can't convert nil into String" error after converting ... did you see this?Diskin
never mind, we fixed this, but did you have an issue converting _id to id in mongoid? "id" is equivalent to "_id" in MM, but it doesn't work that way for mongoid it appears. did you get a chance to send any tips btw? thanks!Diskin
Yes... That is one of the problems that we also had. I'm writing the doc for you now..Baculiform
cool, thanks! perhaps post as an answer, and we can credit you? i hope you found a solution for this because it's killing us right now. may have to stick with MM. :(Diskin
Why are you need to convert _id to id? record.id is the same as record._id in mongoid. I had a problem with it just because another service is using the db data as json, so I had to return id instead, or to change all my service code to _id.Baculiform
yup, same thing as you ... other code relying on .id in the object JSON.Diskin
we found a good solution to the problem: #6892544. please include this in your answer then we can give you the points.Diskin
I posted it as an answer to your question. https://mcmap.net/q/1137946/-advice-on-migrating-from-mongomapper-to-mongoid. I will update it if I would remember more things...Baculiform
I am thinking that in the most simple cases, you won't need either. This works for me: github.com/mongodb/mongo-ruby-driverWendolyn
I too used MongoMapper quite a bit, and decided to start using Mongoid instead.Outlive

© 2022 - 2024 — McMap. All rights reserved.