I’m facing a problem when trying to enter the list = list.new
in the rails console. I get the following error message:
NoMethodError: undefined method `new’ for nil:NilClass
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.8/lib/active_support/whin开发者_如何转开发y_nil.rb:48:in `method_missing’
from (irb):1
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands/console.rb:44:in `start’
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands/console.rb:8:in `start’
from /Users/csamanian/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.8/lib/rails/commands.rb:23:in `’
from script/rails:6:in `require’
from script/rails:6:in `’
Any ideas why? Thanks a lot!
Model names are capitalized by convention in Rails. Try this instead:
list = List.new
You should try this
@list = List.new
精彩评论