From: Phlip Date: 2009-03-21T11:32:12+09:00 Subject: Re: YAML config files with environment specific settings Calvin Nguyen wrote: > 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.