environment.rb uninitialized constant when starting console

764 views
Skip to first unread message

Chris S

unread,
Apr 15, 2008, 1:10:02 PM4/15/08
to Ruby on Rails: Talk
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

Frederick Cheung

unread,
Apr 15, 2008, 1:36:24 PM4/15/08
to rubyonra...@googlegroups.com

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
> Chris
>
> >

Chris S

unread,
Apr 15, 2008, 1:51:30 PM4/15/08
to Ruby on Rails: Talk
That did the trick, thanks Fred.

On Apr 15, 12:36 pm, Frederick Cheung <frederick.che...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages