# YAML config files with environment specific settings

**URL:** <https://www.ruby-forum.com/t/yaml-config-files-with-environment-specific-settings/163505>\
**Category:** Rails\
**Created:** [March 21, 2009, 3:23am UTC](https://www.ruby-forum.com/t/yaml-config-files-with-environment-specific-settings/163505 "2009-03-21T03:23:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubynewbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rubynewbie](https://www.ruby-forum.com/u/rubynewbie)\
**Post date:** [March 21, 2009, 3:23am UTC](https://www.ruby-forum.com/t/yaml-config-files-with-environment-specific-settings/163505/1 "2009-03-21T03:23:27Z")

</div>

I need to store settings by environment but started off simply with my  
config file at: \config\config.yml. The only setting I had was this:  
attachment\_volume: \attach\transfers

With this, cod I’m able to load the file within my initializer and  
reference it just fine from calling code within an ActiveRecord model  
class. So far so good.

Since this setting is a server location that varies by environment, I  
tried to use the by-environment structure and changed my config file  
to this:  
development:  
attachment\_volume: \attach\transfers

test:  
attachment\_volume: \attach\test\transfers

I get the following error during that indicates it didn’t like the  
second instance of the colon on the second line. Here is the real  
error: Uncaught exception: syntax error on line 1, col 20: `  
attachment\_volume: \atlas\transfer\greenlight\predevelopment  
\attachments’

Here is full error stack:

Exiting C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load' C:/Ruby/lib/ruby/1.8/yaml.rb:133:in`load’  
C:/Ruby/lib/ruby/1.8/yaml.rb:144:in `load_file' C:/Ruby/lib/ruby/1.8/yaml.rb:143:in`open’  
C:/Ruby/lib/ruby/1.8/yaml.rb:143:in `load_file' C:/TFS/GreenLight/DEV/server/config/initializers/load_config.rb:2 C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:142:in`load\_without\_new\_constant\_marking’  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:142:in `load' C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:521:in`new\_constants\_in’  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:142:in `load' ./script/../config/../vendor/rails/railties/lib/initializer.rb:550:in`load\_application\_initializers’  
./script/…/config/…/vendor/rails/railties/lib/initializer.rb:549:in  
`each' ./script/../config/../vendor/rails/railties/lib/initializer.rb:549:i n`load\_application\_initializers’  
./script/…/config/…/vendor/rails/railties/lib/initializer.rb:167:in  
`process' ./script/../config/../vendor/rails/railties/lib/initializer.rb:112:in`send’  
./script/…/config/…/vendor/rails/railties/lib/initializer.rb:112:in  
`run' C:/TFS/GreenLight/DEV/server/config/environment.rb:16 C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem\_original\_require’  
C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`require' C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:153:in`require’  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:521:in `new_constants_in' C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:153:in`require’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/…/  
lib/mongrel/rails.rb:147:in `rails' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/ mongrel_rails:113:in`cloaker\_’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel/configurator.rb:149:in `call' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel/configurator.rb:149:in`listener’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/  
mongrel\_rails:99:in `cloaker_' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel/configurator.rb:50:in`call’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/  
mongrel/configurator.rb:50:in `initialize' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/ mongrel_rails:84:in`new’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/  
mongrel\_rails:84:in `run' C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/ mongrel/command.rb:212:in`run’  
C:/Ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/bin/  
mongrel\_rails:281  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:142:in  
`load_without_new_constant_marking' C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:142:in`load’  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:521:in `new_constants_in' C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:142:in`load’  
C:/TFS/GreenLight/DEV/server/vendor/rails/railties/lib/commands/  
servers/mongrel.rb:64  
C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`require’  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:153:in `require' C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/ active_support/dependencies.rb:521:in`new\_constants\_in’  
C:/TFS/GreenLight/DEV/server/vendor/rails/activesupport/lib/  
active\_support/dependencies.rb:153:in `require' C:/TFS/GreenLight/DEV/server/vendor/rails/railties/lib/commands/ server.rb:49 C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem\_original\_require’  
C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`require' ./script/server:3 C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.4/lib/ruby-debug.rb: 101:in`debug\_load’  
C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.4/lib/ruby-debug.rb:  
101:in `debug_program' C:/Ruby/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.4/bin/rdebug-ide:82 C:\Ruby\bin\rdebug-ide:19:in`load’  
C:\Ruby\bin\rdebug-ide:19  
-e:2:in `load' -e:2 Uncaught exception: syntax error on line 1, col 20:`  
attachment\_volume: \atlas\transfer\greenlight\predevelopment  
\attachments’

Has anyone been able to get the by environment structure load to  
work? Please advise? Thanks in advance.
