Created
April 16, 2012 10:17
-
-
Save kfl62/2397516 to your computer and use it in GitHub Desktop.
Logging mongoid in Sinatra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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