以下代码工作得很好:
require 'rubygems' if RUBY_VERSION < '1.9'
require 'sinatra'
get '/' do
greeting = "Hello, World!"
return greeting
end
当我把它放在课堂上时,我收到了错误:
require 'rubygems' if RUBY_VERSION < '1.9'
require 'sinatra'
class Hello
get '/' do
greeting = "Hello, World!"
return greeting
end
end
我收到消息:
hello.rb:5:in '<class:Hello>':undefined method 'get' for Hello:Class (NoMethodError)
from hello.rb:4:in '<main>'
它也不起作用。关于如何使它工作的任何提示?谢谢!