Take the 2-minute tour ×

My team is maintaining a Rails application. The previous developer(s) decided to put some configuration variables (like facebook app id, twitter app id) as env variables. But this is not very versatile. If we have two applications (test and production), we are forced to use only one hardcoded configuration (or changing it manually). Also it is good practice to put these variables in the version control.

Is that the right way to do that? If not, what is the right way?

share|improve this question
What do you mean, "hardcoded"? If you put them in code, then they will be hardcoded. Env vars are the way to go. –  Sergio Tulentsev Feb 11 '13 at 13:32
add comment

1 Answer

We are using following solution in 2 apps.

  1. Store config variables in yml files for https://github.com/railsjedi/rails_config gem.

  2. Apps are configured to use different yml files in production and dev modes via initializers.

  3. On production servers directory with yml files are symlinked with 2 apps.

Task for capistrano looks so:

namespace :settings do
  task :symlink, roles: :app do
    run "ln -s /path_to_settings/#{rail_env} #{current_path}/config/settings"

after "deploy:create_symlink", "settings:symlink"
share|improve this answer
add comment

Your Answer


