environment.rb uninitialized constant when starting console

I have the following code in environment.rb:

require File.join(File.dirname(__FILE__), 'boot')

raw_config = File.read(RAILS_ROOT + "/config/config.yml") APP_CONFIG = YAML.load(raw_config)[RAILS_ENV]

This works fine when running the server, but if I try and start a console I get:

Loading development environment. ./script/../config/../config/environment.rb:15:NameError: uninitialized constant YAML

Can anyone help me out? Thanks.

Chris

I have the following code in environment.rb:

require File.join(File.dirname(__FILE__), 'boot')

raw_config = File.read(RAILS_ROOT + "/config/config.yml") APP_CONFIG = YAML.load(raw_config)[RAILS_ENV]

This works fine when running the server, but if I try and start a console I get:

Loading development environment. ./script/../config/../config/environment.rb:15:NameError: uninitialized constant YAML

Can anyone help me out? Thanks.

You probably need a require 'yaml' before you use yaml. I'm guess that
when you run the server, the server itself loads yaml for its own
purposes before doing the railsy stuff and so you get lucky.

Fred

That did the trick, thanks Fred.