MongoDb MongoMapper and Rails Oh MY!

For the past couple of hours I am trying to insert a simple document
into MongoDb database using Rails and MongoMapper. There is no error
but the document never gets inserted. Here is my simple class:

class Post
include MongoMapper::Document

key :title, String, :required => true
key :description, String


My database.yml file:

adapter: mongodb
host: localhost
database: blog

test: &TEST
adapter: mongodb
host: localhost
database: blog_test

adapter: mongodb
host: localhost
database: blog

and my mongodb.rb file in initializer:

db_config = YAML::load( + “/config/database.yml”))

if db_config[Rails.env] && db_config[Rails.env][‘adapter’] ==
mongo = db_config[‘blog’]
MongoMapper.connection =[‘hostname’])
MongoMapper.database = mongo[‘database’]

And finally here is the controller create action:

def create

post =
post.title = 'title'

redirect_to :action => "new"


Have you used the console to query the MongoDB database and confirm
that a document HASN’T been made?

You could also walk through the steps to create a Post object from the
console and see if that is successful. That should help isolate where
the issue is.

And why are you redirecting to new rather than show for the record or
an index of all records?