Ignore

Please note that your browser is not supported.

We recommend upgrading to the latest Firefox or Google Chrome.

Configuration

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 ./config/application.rb and ./conifg/environment.rb respectively.

Configuring With Blocks

Configuration occurs in one or more configure blocks, like this one in ./config/application.rb:

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: development, test, and production.

Using Dotenv

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 ENV constant.

Here's an example .env file that contains a single key/value pair:

SETTING=value

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.example file 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.

Environment-Specific Dotfiles

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 test environment.

Next Up: Environment