We’ve been using Mongoid 2.4 for one of our projects for quite some times and it has also gone production in a small group for like two month. It works well and I really love this ODM. Thanks to Durran.
Mongoid 3 has been out for like months. Although I have been wanting to try it out, especially when I looked at all the people discussing about it in the Email group, I didn’t find any time to do the upgrade in the last two months. Just yesterday I upgraded to Mongoid 3, and I think the following things are worth noting down.
If you are using
devisefor the user management, you need to clear all the cookies, since Mongoid now uses
Remove setting of
Mongoid.add_language. It is removed since custom application exceptions in various languages has been removed.
Remove setting of
application.rband replace it with
Mongoid.logger=in your Mongoid initializer or some place else equally, since the
loggersetting is moved to the top level.
Look for all places which uses
store_insyntax, it has been changed to a more complex one which provides much more complete features, check it out here: Mongoid: Persistence
Remember to change all
About sort: syntax of
Criteria#order_byhas changed a little bit,
Posts.all.order_by(:name, :desc)which worked in 2.4 will throw you an exception of
NoMethodError (undefined method '__sort_option__' for :accurate_created_at:Symbol):in Mongoid 3.0. But you could change to
Posts.all.desc(:name). I liked the latter one a lot.
Criteria#count(true)was a way to tell mongoid to count with respect to
limitinside the queries in Mongoid 2. Now it’s removed since it would cause an additional call to DB, which is unnecessary as the result is already in your memory. You could use
That’s all I’ve done in my upgrade to Mongoid 3. It’s not all you might run into when you upgrade, so definitely remember to check out this one: Mongoid Upgrade