Skip to content

Instantly share code, notes, and snippets.

@orlando
Forked from jacquescrocker/database.rb
Created June 28, 2011 19:08
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 orlando/1051927 to your computer and use it in GitHub Desktop.
Save orlando/1051927 to your computer and use it in GitHub Desktop.
configures padrino to use config/mongoid.yml
# config/database.rb
config_file = Padrino.root("config", "mongoid.yml")
if File.exists?(config_file)
settings = YAML.load(ERB.new(File.read(config_file)).result)[Padrino.env.to_s]
::Mongoid.from_hash(settings) if settings.present?
end
# config/mongoid.yml
options: &options
parameterize_keys: false
defaults: &defaults
host: localhost
# slaves:
# - host: slave1.local
# port: 27018
# - host: slave2.local
# port: 27019
development:
<<: *defaults
<<: *options
database: tweetup_dev
test:
<<: *defaults
<<: *options
database: tweetup_test
production:
<<: *options
uri: <%= ENV['MONGOHQ_URL'] %>
database: tweetup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment