Skip to content

Instantly share code, notes, and snippets.

@adriancb
Forked from garrensmith/mongoid-sinatra-demo.rb
Created April 17, 2012 07:02
Show Gist options
  • Save adriancb/2404100 to your computer and use it in GitHub Desktop.
Save adriancb/2404100 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'mongoid'
configure do
Mongoid.configure do |config|
name = "demo"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.slaves = [
Mongo::Connection.new(host, 27017, :slave_ok => true).db(name)
]
config.persist_in_safe_mode = false
end
end
get '/' do
person = Person.new(:first_name => "Ludwig", :last_name => "Beethoven")
person.save
"Hello, I am #{person.first_name} #{person.last_name}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment