Skip to content

Instantly share code, notes, and snippets.

@kfl62
Created April 16, 2012 10:17
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 kfl62/2397516 to your computer and use it in GitHub Desktop.
Save kfl62/2397516 to your computer and use it in GitHub Desktop.
Logging mongoid in Sinatra
# encoding: utf-8
require 'mongoid'
# Connection.new takes host, port
host = 'localhost'
port = Mongo::Connection::DEFAULT_PORT
database_name = case ENV['RACK_ENV'].to_sym
when :development then 'varena'
when :production then 'varena'
when :test then 'varena_test'
end
Mongoid.configure do |config|
config.master = Mongo::Connection.new(host, port, logger: Logger.new($stdout)).db(database_name)
config.raise_not_found_error = false
end
desc "Irb with DB environment loaded"
task :console do
require './config/database'
require "irb"
ARGV.clear
IRB.start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment