-
Notifications
You must be signed in to change notification settings - Fork 73
Config
Pedro Belo edited this page Jul 14, 2015
·
2 revisions
Pliny takes all of its configuration parameters via environment variables.
Take a look at config/config.rb
whenever you need to read or set new parameters. It relies on Pliny helpers to validate, cast and set default values for env vars.
Lets say you're adding a Redis cache to your app.
The first step is to set a new, required Config
:
module Config
extend Pliny::CastingConfigHelpers
mandatory :redis_url, string
end
Now use this interface instead of going to ENV
directly:
redis = Redis.new(url: Config.redis_url)
If REDIS_URL
is not present in the environment you're going to see this error when trying to access it:
lib/pliny/config_helpers.rb:4:in `fetch': key not found: "REDIS_URL" (KeyError)
Fix it by setting the env var in .env
(the address of your local Redis) and in .env.sample
(the default value for new developers):
REDIS_URL=redis://localhost:6379
Basics
Diving in
- bin/setup
- Config
- CORS
- Endpoints
- Error Handling
- Logging
- Models
- Mediators
- Migrations
- Rake Tasks
- Request IDs
- RequestStore
- Schema
- Serialization
- Testing
- Updating
Guides