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?

canoe
  • 1,273
  • 13
  • 29

1 Answers1

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:

Community
  • 1
  • 1
user2503775
  • 4,267
  • 1
  • 23
  • 41
  • did you have any issues switching? we're thinking about switching too and would love any advice. – Crashalot Jan 02 '14 at 23:39
  • Yes,sure.. Do you want me to send you a document, with all the issues switching? – user2503775 Jan 05 '14 at 09:36
  • we ran into a "TypeError: can't convert nil into String" error after converting ... did you see this? – Crashalot Jan 06 '14 at 07:57
  • 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! – Crashalot Jan 06 '14 at 08:18
  • Yes... That is one of the problems that we also had. I'm writing the doc for you now.. – user2503775 Jan 06 '14 at 08:19
  • 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. :( – Crashalot Jan 06 '14 at 08:26
  • 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`. – user2503775 Jan 06 '14 at 08:53
  • yup, same thing as you ... other code relying on .id in the object JSON. – Crashalot Jan 06 '14 at 09:06
  • we found a good solution to the problem: http://stackoverflow.com/questions/6892044/add-virtual-attribute-to-json-output. please include this in your answer then we can give you the points. – Crashalot Jan 06 '14 at 09:15
  • I posted it as an answer to your question. http://stackoverflow.com/a/20947620/2503775. I will update it if I would remember more things... – user2503775 Jan 06 '14 at 10:16
  • I am thinking that in the most simple cases, you won't need either. This works for me: https://github.com/mongodb/mongo-ruby-driver – kgpdeveloper Feb 23 '14 at 21:25
  • I too used MongoMapper quite a bit, and decided to start using Mongoid instead. – B Seven Jun 03 '15 at 22:22