Skip to content

Instantly share code, notes, and snippets.

@hone
Created August 20, 2011 01:13
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 hone/04a8aea95f7b6adce6c6 to your computer and use it in GitHub Desktop.
Save hone/04a8aea95f7b6adce6c6 to your computer and use it in GitHub Desktop.
diff --git a/lib/mongoid/railtie.rb b/lib/mongoid/railtie.rb
index 1a2cf40..dbbd26f 100644
--- a/lib/mongoid/railtie.rb
+++ b/lib/mongoid/railtie.rb
@@ -59,7 +59,8 @@ module Rails #:nodoc:
#
initializer "setup database" do
config_file = Rails.root.join("config", "mongoid.yml")
- if config_file.file?
+ if config_file.file? &&
+ YAML.load(ERB.new(File.read(config_file)).result)[Rails.env].values.flatten.any?
::Mongoid.load!(config_file)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment