Benjamin Curtis

Speculations on Web Development

Quick Tip: MongoMapper::DocumentNotFound

| Comments

If you’d like to get a 404 response when you encounter a MongoMapper::DocumentNotFound error, which is the default response for ActiveRecord::RecordNotFound, simply toss this in your initializer where you set up your Mongo connection (I use config/initializers/mongo.rb):

ActionController::Base.rescue_responses[‘MongoMapper::DocumentNotFound’] = :not_found

Comments