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

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 nrun’
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:inrequire’
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:innew_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:inrails’
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:incall’
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:incloak 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 :ininitialize’
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:inrun’
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:inload’
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:innew_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:ingem_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:inrequire’
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:inrequire’
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:inrequire’
from script/server:3

Thank you in advance!

  • John

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
[email protected]

Rob,

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

Thanks

  • John