Permalink
Browse files

syntax highlighted Readme

  • Loading branch information...
1 parent 9c2d80f commit b775b4ed6572b58be4c606e0cd9fc3041295b78d @mislav committed Dec 12, 2012
Showing with 46 additions and 30 deletions.
  1. +46 −30 README.md
View
@@ -1,49 +1,65 @@
-The choice is yours
-===================
+Choices for Rails
+=================
Easy-peasy external settings for your Rails app.
- # Gemfile
- gem 'choices'
+~~~ rb
+# Gemfile
+gem 'choices'
+~~~
In your app initializer block:
- config.from_file 'settings.yml'
+~~~ rb
+config.from_file 'settings.yml'
+~~~
-This will read configuration from "config/settings.yml" and, additionally, "settings.local.yml" if it exists. You should check the main file into version control, but not the ".local" file which is to be used for per-machine configuration: tweaks in development or private keys in production, for example.
+This will read configuration from "config/settings.yml" and, additionally,
+"settings.local.yml" if it exists. You should check the main file into version
+control, but not the ".local" file which is to be used for per-machine
+configuration: tweaks in development or private keys in production, for example.
- # .gitignore
- config/settings.local.yml
+~~~
+# .gitignore
+config/settings.local.yml
+~~~
-Configuration files can contain ERB; this is useful for reading in Heroku configuration. For example:
+Configuration files can contain ERB; this is useful for reading in dynamic
+config such as from environment variables:
- # settings.yml
- defaults: &defaults
- secret_token: <%= ENV['COOKIE_SECRET'] %>
- heroku: <%= !!ENV['HEROKU_TYPE'] %>
- mongodb:
- uri: <%= ENV['MONGOHQ_URL'] %>
+~~~ yaml
+# settings.yml
+defaults: &defaults
+ secret_token: <%= ENV['COOKIE_SECRET'] %>
+ heroku: <%= !!ENV['HEROKU_TYPE'] %>
+ mongodb:
+ uri: <%= ENV['MONGOHQ_URL'] %>
- development:
- <<: *defaults
+development:
+ <<: *defaults
- test: &testing
- <<: *defaults
- secret_token: <%= "banana" * 5 %>
- mongodb:
- database: myapp_test
+test: &testing
+ <<: *defaults
+ secret_token: <%= "banana" * 5 %>
+ mongodb:
+ database: myapp_test
- cucumber:
- <<: *testing
+cucumber:
+ <<: *testing
+~~~
The ".local" file can contain overrides for your development environment:
- # settings.local.yml
- development:
- mongodb:
- database: myapp_dev
+~~~ yaml
+# settings.local.yml
+development:
+ mongodb:
+ database: myapp_dev
+~~~
Finally, the config keys can be read in your app as such:
- Rails.configuration.heroku #=> false
- Rails.configuration.mongodb.database #=> "myapp_dev"
+~~~ rb
+Rails.configuration.heroku #=> false
+Rails.configuration.mongodb.database #=> "myapp_dev"
+~~~

0 comments on commit b775b4e

Please sign in to comment.