In one of my applications, I have the following config files that are excluded from git:
* config/mongoid.yml
* config/application.yml
* config/mailserver_setting.rb
* config/omniauth_settings.rb
For deploying to a regular server, I just add tasks to my capistrano deployment file to create sym-links to a shared directory. In this case I have to modify my application to use local ENV files and consequently the ENV hash in my rails app.
In my configuration.rb (boots at initialization):
config_file = File.expand_path('../../config/application.yml', __FILE__) if File.exist?(config_file) APPLICATION_CONFIG=YAML.load_file(config_file)[Rails.env]['application'] CONSTANTS=YAML.load_file(config_file)[Rails.env]['constants'] APPLICATION_CONFIG.each{|k,v| ENV["APPLICATION_CONFIG_#{k}"] = v.to_s } CONSTANTS.each{|k,v| ENV["CONSTANTS_#{k}"] = v.to_s} end
So using the following custom thor task, I can load heroku’s env files based on some code from Les Hill:
This works well.
Leave a Reply