Skip to content

Instantly share code, notes, and snippets.

@jacquescrocker
Created April 10, 2011 19:50
Show Gist options
  • Save jacquescrocker/912656 to your computer and use it in GitHub Desktop.
Save jacquescrocker/912656 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
@rafapolo
Copy link

or just remove database.rb and put
Mongoid.load!("config/mongoid.yml")
at boot.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment