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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-15 17:36 UTC
Re: environment.rb uninitialized constant when starting console
On 15 Apr 2008, at 18:10, Chris S wrote:> > 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> Chris > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris S
2008-Apr-15 17:51 UTC
Re: environment.rb uninitialized constant when starting console
That did the trick, thanks Fred. On Apr 15, 12:36 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 15 Apr 2008, at 18:10, Chris S wrote: > > > > > > > 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 > > > Chris--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- numeric key in yam file to be used by config file
- Reading Yaml files and getting an 'uninitialized constant ActionView::CompiledTemplates' Error
- Rails 3 Foreign Domain routing - cannot get this to work!
- RSpec and the Basecamp API
- Can't configure cach_store in an initializer