0
我正在關注Ruby on Rails的Kevin Skoglund教程,名爲Ruby on Rails 4 Essential Training。正如我仍然在學習的初期階段,我不能確定的原因可能是什麼,儘管它似乎Ruby on Rails創建記錄時出錯
George$ pwd
/Users/George/Sites/simple_cms
George$ rails console
Loading development environment (Rails 4.2.0)
irb(main):001:0> subject = Subject.new
NameError: uninitialized constant Subject
from (irb):1
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/George/Sites/simple_cms/bin/rails:8:in `<top (required)>'
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/George/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
irb(main):002:0>
:在節「創建記錄」我以後只是想創建一個記錄具有下列錯誤根據錯誤回報進行寶石相關。
如果任何人有任何建議,並可能提示如何我可以弄清楚什麼是錯誤和修復是我自己,這將不勝感激,因爲我真的想繼續學習。
你有叫'主題'的模型或類嗎? – 2015-01-09 20:50:34
您是否運行了本教程的「生成模型」部分中引用的「rails generate model Subject」命令?這應該在app/models目錄中創建了一個名爲'subject.rb'的文件,其中包含一個名爲'Subject'的類。你得到的錯誤是說'Subject'類無法找到(這與寶石無關)。 – 2015-01-09 20:57:24