Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Mongoid extension for Sinatra.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 sinatra-mongoid.gemspec
README.md

Sinatra Mongoid

A Mongoid extension for Sinatra.

Usage

Gemfile:

gem 'sinatra'
gem 'sinatra-mongoid', :require_as => 'sinatra/mongoid'

Bundle:

gem bundle

Create your Sinatra app:

require File.dirname(__FILE__) + '/vendor/gems/environment'
Bundler.require_env

set :mongo_db, 'db-name'

Configuration

All Sinatra options you can set are:

:mongo_host
:mongo_db
:mongo_port
:mongo_user
:mongo_password

Their default values are:

ENV['MONGOID_HOST']     || 'localhost'
ENV['MONGOID_DATABASE'] || 'changme'
ENV['MONGOID_PORT']     || Mongo::Connection::DEFAULT_PORT
ENV['MONGOID_USERNAME']
ENV['MONGOID_PASSWORD']

Heroku & MongoHQ:

require 'uri'

if ENV['MONGOHQ_URL']
    mongo_uri = URI.parse(ENV['MONGOHQ_URL'])
    ENV['MONGOID_HOST'] = mongo_uri.host
    ENV['MONGOID_PORT'] = mongo_uri.port.to_s
    ENV['MONGOID_USERNAME'] = mongo_uri.user
    ENV['MONGOID_PASSWORD'] = mongo_uri.password
    ENV['MONGOID_DATABASE'] = mongo_uri.path.gsub("/", "")
end

Resources

Authors

Dan Croak, Justin Reidy.

Something went wrong with that request. Please try again.