-
Notifications
You must be signed in to change notification settings - Fork 7
Mongo
Dale Campbell edited this page Jul 2, 2013
·
8 revisions
If your collection looks like this:
$ mongo
MongoDB shell version: 2.0.4
connecting to: test
> use app_config
switched to db app_config
> db.app_config.find()
{ "_id" : ObjectId("4cddc317da98dd42f8000001"), "admin_email" : "[email protected]" }
Setup AppConfig like so:
# These are the defaults:
mongo_opts = {
:host => 'localhost',
:port => '27017',
:database => 'app_config',
:collection => 'app_config'
}
AppConfig.setup!(:mongo => mongo_opts)
Then use the stored values:
AppConfig.admin_email # => '[email protected]'
Config variables can be created (or updated) and then saved back to the database:
AppConfig.admin_email = '[email protected]'
AppConfig.api_key = SuperAwesomeKeyGenerator.generate_key!
AppConfig.save!