Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Logging mongoid in Sinatra

View Rakefile
1 2 3 4 5 6 7
desc "Irb with DB environment loaded"
task :console do
require './config/database'
require "irb"
ARGV.clear
IRB.start
end
View Rakefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.