Darko Fabijan wrote this on September 21, 2010

Two beginner Mongo notes

Problem: mongod doesn’t start and the tail of /var/log/mongodb/mongod.log says :

Mon Sep 20 12:00:16 exception in initAndListen std::exception: old lock file, terminating

Solution: you somehow did not shut down the machine properly the last time. Remove the old lock file:

sudo rm /var/lib/mongodb/mongod.lock

And if you’re on Ubuntu, you can use the new Upstart syntax to start the process via the init.d script that the package from 10gen PPA provides:

sudo start|stop mongodb

Problem: given the following Mongoid document:

class Post
  include Mongoid::Document
  field :tags, :type => Array

you’d like to find all posts that contain a certain tag.

Solution: use any_in criteria. It may not be obvious from the docs, but it does apply to fields of type Array too:

Post.any_in(:tags => [t])
comments powered by Disqus

About Darko Fabijan

Rendered Text co-founder. Enjoys breaking new ground and exploring tools and ideas that make lives of developers interesting and productive. Nowadays has less time to write code but has great pleasure in discussing it with the team. He spends his free time cooking, hiking and indoor gardening.

Suggested Reads

Rails Testing Handbook

A new ebook on building test-driven Rails apps with RSpec and Cucumber.

At Rendered Text, we have a long history with Ruby on Rails. Checking the blog archive reminds me that we published first posts about working with Rails way back in 2009.


Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.