Error running 'ruby script/console' => "uninitialized consta

Hi,

Anyone suggest why when I try to run the console via ‘ruby
script/console’ I
get the following “uninitialized constant RAILS_ROOT” ??

Error:

V:\Source\testapp>ruby script\console
Loading development environment.
./script/…/config/…/config/environment.rb:3:NameError: uninitialized
constant RAILS_ROOT
C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:252:in require': no such file to load -- console_app (LoadError) from C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:252:inload_modules’
from C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:250:in
load_modules' from C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:21:insetup’
from C:/InstantRails/ruby/lib/ruby/1.8/irb.rb:54:in `start’
from C:/InstantRails/ruby/bin/irb.bat:20

environment.rb

require “#{RAILS_ROOT}/config/nested_layout.rb”

ENV[‘RAILS_ENV’] ||= ‘production’

RAILS_GEM_VERSION = ‘1.1.6’

require File.join(File.dirname(FILE), ‘boot’)

Rails::Initializer.run do |config|
end

module ActiveRbacConfig
config :controller_layout, “contacts”
end
Engines.start :active_rbac
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(:default
=> ‘%H:%M:%S %d-%m-%Y’) # e.g. 10-31-2006 @ 9:30 PM
LOCALES = {‘en’ => ‘en’, ‘fr’ => ‘fr’}.freeze

Thanks
Greg

Greg,

In your environment.rb, try moving the first line
require “#{RAILS_ROOT}/config/nested_layout.rb”

and put it AFTER the line that goes
require File.join(File.dirname(FILE), ‘boot’)

I’m not sure what nested_layout.rb is supposed to do, but RAILS_ROOT
won’t work until the boot process is complete.

Alternately, if that doesn’t work, you can try replacing that first line
with:
require File.join(File.dirname(FILE), ‘nested_layout.rb’)

(since your environment.rb is already in the config directory.)

Daniel A.
Zoodango.com

Greg H. wrote:

Hi,

Anyone suggest why when I try to run the console via ‘ruby
script/console’ I
get the following “uninitialized constant RAILS_ROOT” ??

Error:

V:\Source\testapp>ruby script\console
Loading development environment.
./script/…/config/…/config/environment.rb:3:NameError: uninitialized
constant RAILS_ROOT
C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:252:in require': no such file to load -- console_app (LoadError) from C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:252:inload_modules’
from C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:250:in
load_modules' from C:/InstantRails/ruby/lib/ruby/1.8/irb/init.rb:21:insetup’
from C:/InstantRails/ruby/lib/ruby/1.8/irb.rb:54:in `start’
from C:/InstantRails/ruby/bin/irb.bat:20

environment.rb

require “#{RAILS_ROOT}/config/nested_layout.rb”

ENV[‘RAILS_ENV’] ||= ‘production’

RAILS_GEM_VERSION = ‘1.1.6’

require File.join(File.dirname(FILE), ‘boot’)

Rails::Initializer.run do |config|
end

module ActiveRbacConfig
config :controller_layout, “contacts”
end
Engines.start :active_rbac
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(:default
=> ‘%H:%M:%S %d-%m-%Y’) # e.g. 10-31-2006 @ 9:30 PM
LOCALES = {‘en’ => ‘en’, ‘fr’ => ‘fr’}.freeze

Thanks
Greg

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs