Reputation: 359
Working through Rails Tutorial; I'm in the Rails Console mode, or rather, Development Mode, by running 'rails console'. I'm following Hartl's great tutorial, and I'm presented with:
NoMethodError: undefined method `empty?' for nil:NilClass
from (irb):7
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
when I run: 'nil.empty?'
and in Hartl's tutorial it shows this as being presented after running the command:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
My question is, what is all the additional details with my directory, and the different folders (what it looks like)?
Learning Rails, thanks for the tips.
Upvotes: 0
Views: 198
Reputation:
If you're referring to /Users/coreymkimball/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0
... lines, that's the stacktrace.
Essentially it shows you what went wrong, and the relevant lines of code.
Since you're in the rails console
, which is essentially irb
, that's what it's saying in the from (irb):7
line - that's where you called the empty?
method.
In your case, you attempted to call empty?
method on something that was apparently an object of the NilClass
. Since it doesn't know how to respond to empty?
it threw a NoMethodError
.
Upvotes: 1