Forum: Ruby on Rails Help with debugging - undefined method `[]' for nil:NilClass (NoMethodError) ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
John B. (Guest)
on 2008-10-04 21:27
(Received via mailing list)
Hello all,

Question for you all... I never came across this yet, I have an app
where in developement it works perfect, but when I tried to launch it
in production mode I received the following error below..   How can I
figure out what undefined method is?

/filestore/files/projects/keith/config/environment.rb:56: undefined
method `[]'                         for nil:NilClass (NoMethodError)

More details:

** Starting Rails with production environment...
Exiting
/filestore/files/projects/keith/config/environment.rb:56: undefined
method `[]'                         for nil:NilClass (NoMethodError)
        from ./script/../config/../vendor/rails/railties/lib/
initializer.rb:95:i                        n `run'
        from /filestore/files/projects/keith/config/environment.rb:18
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_re                        quire'
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`require'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:510:in `require'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:355:in `new_constants_in'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:510:in `require'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/
rails.rb:14                        7:in `rails'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:
113:in `cloa                        ker_'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
configurator.rb:14                        9:in `call'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
configurator.rb:14                        9:in `listener'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:
99:in `cloak                        er_'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
configurator.rb:50                        :in `call'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
configurator.rb:50                        :in `initialize'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:
84:in `new'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:
84:in `run'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/
command.rb:212:in                         `run'
        from /var/lib/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:
281
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:503:in `load'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:503:in `load'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:355:in `new_constants_in'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:503:in `load'
        from /filestore/files/projects/keith/vendor/rails/railties/lib/
commands/                        servers/mongrel.rb:64
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_re                        quire'
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`require'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:510:in `require'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:355:in `new_constants_in'
        from /filestore/files/projects/keith/vendor/rails/
activesupport/lib/acti                        ve_support/
dependencies.rb:510:in `require'
        from /filestore/files/projects/keith/vendor/rails/railties/lib/
commands/                        server.rb:39
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_re                        quire'
        from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`require'
        from script/server:3

Thank you in advance!
- John
Rob B. (Guest)
on 2008-10-04 21:43
(Received via mailing list)
On Oct 4, 2008, at 1:24 PM, John wrote:

> Hello all,
>
> Question for you all... I never came across this yet, I have an app
> where in developement it works perfect, but when I tried to launch it
> in production mode I received the following error below..   How can I
> figure out what undefined method is?
>
> /filestore/files/projects/keith/config/environment.rb:56: undefined
> method `[]'                         for nil:NilClass (NoMethodError)


Have you looked at what is on that line?  No one can even begin to
help without knowing that.

-Rob

Rob B.    http://agileconsultingllc.com
removed_email_address@domain.invalid
John B. (Guest)
on 2008-10-04 23:31
(Received via mailing list)
Rob,

I figured it out, I was referencing a variable that didnt exist.

Thanks
 - John
This topic is locked and can not be replied to.