我正在做 Mike Hartl 的 Rails 教程和第 4.4.2 节“类继承”。具体来说,当尝试在 Rails 控制台中创建一个根据“清单 4.8”从 String 类继承的类时,我在执行它时收到以下错误。
irb(main):001:0> class Word < String
#<Class:0x56fc868>: undefined local variable or method `ti' for main:Object
from (irb):25
from d:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from d:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from d:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):026:0> class Word < String
#<Class:0x54a1178>: undefined local variable or method `asodSrlsW' for main:Object
from (irb):1
from d:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from d:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from d:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
更奇怪的是......当我尝试再次执行同一行代码来创建类时,我想也许我只是有一个错字,我得到一个稍微不同的错误,这没有任何意义。由于我感到困惑,因此非常感谢对此的任何指导。