Oct 17 2010
∞
Handy Bits for Mongoid with Rails 3
Rails 3 and Mongoid are just peachy. Here are a couple of development conveniences for using them together.
Pop this snippet in your ~/.irbrc to show the raw JavaScript queries that Mongoid is running as you play with your app in the Rails console (and/or SQL, when you’re using ActiveRecord). Formatting isn’t great for Mongo queries, but it’s helpful nonetheless.
Setting autocreate_indexes to false will spare you some log noise. It’s also worth noting that Hirb works nicely out of the box for Mongoid documents, and I heartily recommend it.
And here’s a db:console Rake task to stand in for the rails dbconsole command that won’t work with Mongoid: