Skip to content

Instantly share code, notes, and snippets.

@lucianosousa
Created September 15, 2010 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucianosousa/581621 to your computer and use it in GitHub Desktop.
Save lucianosousa/581621 to your computer and use it in GitHub Desktop.
mongo_mapper in sinatra
#models.rb
require 'rubygems'
require 'mongo'
require 'mongo_mapper'
class Post
include MongoMapper::Document
key :title, String
key :content, String
end
ree-1.8.7-2010.02 > require 'rubygems'
ree-1.8.7-2010.02 > require 'mongo'
ree-1.8.7-2010.02 > require 'mongo_mapper'
ree-1.8.7-2010.02 > MongoMapper.connection = Mongo::Connection.new('localhost')
ree-1.8.7-2010.02 > MongoMapper.database = 'mysite'
ree-1.8.7-2010.02 > require 'models'
ree-1.8.7-2010.02 > post = Post.create({ :title => 'Titulo do post', :content => 'Conteudo do post'})
ree-1.8.7-2010.02 > post.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment