Overriding default id in mongoid

This is an easy one, just want to make sure it’s clear. Add the following field to your model: field :_id, type: Moped::BSON::ObjectId And to allow setting it: 1 def id=(id) 2 self[:_id] = id 3 end Now you can just do obj.id=[Some ObjectId] and save the object.

November 15, 2014 · 1 min · Chen Kinnrot

Rails + Mongo + Heroku how?

After a few hours of fighting with google I decided to write it all here: *This post is more relevant for windows users but can help others. What do you need to have: First you need to have ruby 1.9.2+ Devkit then you need rails 3+ then u need the bundler gem then go to getting started with mongoid then install mongo locally then check it all good then add account in heroku then create app then add your key then push

March 28, 2012 · 1 min · Chen Kinnrot