0

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?

1
  • What do you mean, "hardcoded"? If you put them in code, then they will be hardcoded. Env vars are the way to go. Commented Feb 11, 2013 at 13:32

1 Answer 1

1

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"
  end
end

after "deploy:create_symlink", "settings:symlink"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.