我正在尝试首先在我用代码创建的helloworld.ru目录中创建一个rake basic应用程序
类类型定义调用(环境) "200",{“Content- HelloRack”=>“文本/纯文本”},"Hello World“结束运行HelloRack.new
我用rackup helloworld.ru运行它,它工作得很好,之后我用代码在同一目录下创建了三个文件Massive.rb
module Rack
class Massive
def initialize(app)
@app = app
end
def call(env)
status, headers, response= @app.call(env)
[status, headers, "<div style="font-size:5.0em">#{response} - it's all small stuff</div>"]
end
end
end和其他文件的名称是SmallStuff.rb
class SmallStuff
def call(env)
["200", {"Content-Type" => "text/html"}, "Don't Sweat The Small Stuff"]
end
end还有一个文件名是config.ru,代码是
require 'rubygems'
require 'rack'
use Rack::Massive
run SmallStuff.new当我运行rackup config.ru时,它给我错误
/home/ritesh/rails/config.ru:4: uninitialized constant Rack::Massive (NameError)
from /var/lib/gems/1.8/gems/rack-1.4.4/lib/rack/builder.rb:51:in `instance_eval'
from /var/lib/gems/1.8/gems/rack-1.4.4/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/rails/config.ru:0:in `new'
from /home/ritesh/rails/config.ru:0如何删除这个错误我是rake应用程序的新手,可以请任何人提供rake应用程序教程或有用的链接!
发布于 2013-01-29 01:50:55
看起来你只是少了一两个Ruby文件,首先将你的其他文件重命名为massive.rb和small_stuff.rb (遵循require约定),然后要求它们如下所示:
require 'rubygems'
require 'rack'
require_relative './massive'
require_relative './small_stuff'
use Rack::Massive
run SmallStuff.newhttps://stackoverflow.com/questions/14567838
复制相似问题