0

有谁知道是什么导致了这个错误?我正在尝试制作一个基本的机架应用程序。

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

编辑:显然我忘了包括错误呜呜声:

/local/www/cherry/lib/app.rb:12:in 'instance_eval': block not supplied (ArgumentError)

4

1 回答 1

0

解决它!显然你需要在Cherry.app do..块周围的括号:

run(Cherry.app do
    "Hello World"
end)
于 2012-08-29T10:41:35.487 回答