I have a Rails application which I now plan to deploy many instances to different domains. Originally I only intend for it to be on one domain.
I realize that for each domain, I have to replace all the hard-coded values in various places. These include:
- asset host path (assets reside on the same domain)
- whenever-gem’s :application setting (since two domain can share the same server, and this is to avoid crobtab update clash)
- some of tasks which uses curl to its own address to trigger events
- carrierwave needs a hardcoded value when computing image full url without the request object.
Question
Is there a strategy to set this, so:
- the setting should not be commited into source control (like
database.yml.example) - Codes outside Rails can access it (whenever-gem does not load Rails environment)
- Ways to access the domain can be consistent
One approach you can take is to have a YAML file with per deployment properties. You could even check the development version in and have your deploy scripts overwrite with the correct version.
Typically I’d put that configuration file in shared/config (assuming a capistrano style layout) and then symlink it into the current release during the deploy.