Skip to content

Instantly share code, notes, and snippets.

@cmelbye
Created September 16, 2010 01:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmelbye/581833 to your computer and use it in GitHub Desktop.
Save cmelbye/581833 to your computer and use it in GitHub Desktop.
diff --git a/config/initializers/_mongo.rb b/config/initializers/_mongo.rb
index 2764f97..88d21ec 100644
--- a/config/initializers/_mongo.rb
+++ b/config/initializers/_mongo.rb
@@ -2,10 +2,12 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
+require "uri"
-MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
+uri = URI.parse(ENV['MONGOHQ_URL'])
+MongoMapper.connection = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
-MongoMapper.database = "diaspora-#{Rails.env}"
+MongoMapper.database = uri.path.gsub(/^\//, '')
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment