Permalink
Browse files

Handle if URI only has a /

  • Loading branch information...
1 parent 8041267 commit 5d02cc1046759e7ab7944884623f44de1ef45966 @bkeepers bkeepers committed Sep 26, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 config/initializers/mongo.rb
View
8 config/initializers/mongo.rb
@@ -1,5 +1,7 @@
-uri = URI.parse ENV["GH_MONGODB_URL"] || ENV["MONGODB_URI"] || ENV["MONGOHQ_URL"]
-conn = Mongo::Connection.from_uri(uri.to_s)
-db = conn.db(uri.path.blank? ? "swordfish-#{Rails.env}" : uri.path.sub('/', ''))
+uri = URI.parse ENV["GH_MONGODB_URL"] || ENV["MONGODB_URI"] || ENV["MONGOHQ_URL"]
+conn = Mongo::Connection.from_uri(uri.to_s)
+database = uri.path.sub('/', '')
+database = "swordfish-#{Rails.env}" if database.blank?
+db = conn.db(database)
Swordfish::Application.config.mongo = db

0 comments on commit 5d02cc1

Please sign in to comment.