3
use Rack::Static, :urls => ['/stylesheets', '/images'], :root => 'public'

run proc { |env| [200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' }, File.open('public/index.html')] }

我调用 Rack::File:Class 的私有方法“打开”。实在看不出问题出在哪里。运行机架 1.1。请帮忙...

4

1 回答 1

3

Rack::File由于 Ruby 查找名称的方式,有一个类在您的 rackup 文件中具有优先权。这不是你要找的类,你想要 Ruby 自己的File类。可以通过使用前缀直接引用该类,而不会出现查找歧义::

::File.open('public/index.html')
于 2010-03-23T22:07:16.433 回答