有人知道造成这个错误的原因是什么吗?我正在尝试制作一个基本的机架应用程序。
App.rb =>
class Cherry
class << self
def app &block
Cherry::Application.new &block
end
end
class Application
def initialize &block
instance_eval &block
end
def print_start_message
puts "Starting server"
end
def call env
[200, {"Content-type" => "text/plain"}, "Hello World"]
end
end
end
Config.ru =>
require 'app'
run Cherry.app do
print_start_message
end
编辑:显然我忘了包含错误woops:
/local/www/cherry/lib/app.rb:12:in 'instance_eval': block not supplied (ArgumentError)
答案 0 :(得分:0)
修正了它!显然你需要围绕Cherry.app do..
块的括号:
run(Cherry.app do
"Hello World"
end)