Pakyow ships fully configured with the most useful conventions for most projects. These conventions let you hit the ground running by reducing the number of decisions you need to make. But the framework shouldn't tie your hands, so we've designed the framework to be highly configurable to your specific needs.
There are two main areas of configuration: the application and the environment where the application runs. These configuration files can be found at
Configuring With Blocks
Configuration occurs in one or more
configure blocks, like this one in
Pakyow.app do configure do config.option = :value end end
Configuration blocks are called during the initialization process. Each block accepts an optional parameter that defines what environment the configuration block should be called in. This allows you to use one set of values in development, another in production, and so on. When the environment is unspecified, the configuration block applies to all environments.
Pakyow.app do configure do config.option = :global_value end configure :development do config.option = :development_value end configure :production do config.option = :production_value end end
Default configuration exists for each of the following environments:
Dotenv files are the standard way to manage secret values—such as an api key—or values specific to an individual development environment—such as a database connection string. Projects are generated with the dotenv integration by default. When the project boots up, values from a
.env file located in the project root are loaded into Ruby's
Here's an example
.env file that contains a single key/value pair:
These values can now be used to replace the hardcoded values in the configure blocks:
Pakyow.app do configure do config.setting = ENV["SETTING"] end end
Here are some recommendations when using dotenv:
- Don't keep dotenv files in version control. This is no better than hardcoding the values.
- Create a
.env.examplefile with necessary keys and values and a brief explanation of how they're used. Do keep this file in version control as the canonical reference that other developers can use.
The dotenv integration will also load any environment-specific dotfiles that are present. For example, values from
.env.test will be loaded when booting Pakyow in the