YAML config files with environment specific settings



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.
--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: YAML config files with environment specific settings
    ... cod I'm able to load the file within my initializer and ... tried to use the by-environment structure and changed my config file to ... error: Uncaught exception: syntax error on line 1, ...
    (comp.lang.ruby)
  • Re: Busting "java.lang.outofmemory"
    ... > I'm of the opinion that something like an "OutOfMemoryError" and just about ... Like program designed to load up to 50 images is asked to ... Yes, it might be a problem with the environment, ...
    (comp.lang.java.programmer)
  • Re: Open Source QA Tools
    ... Depends on what you mean by 'decent', what the environment is and what ... level of load your looking to achieve. ... load and stress testing. ...
    (comp.software.testing)
  • Re: Pluggable Modules
    ... >properties file with plugins specified? ... obscure file somewhere he has to load into a text editor to edit ... themselves and update the config file. ...
    (comp.lang.java.programmer)
  • XmlReader Question
    ... parses the config file many times and I do not want to load the config file ... The problem is I am using XMLReader because of speed and after I ...
    (microsoft.public.dotnet.languages.csharp)

Loading