开发者

Rack throwing an error when trying to serve a static file

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')] }

I get private method `open' called for Rack::File:Class when I rackup. Really can't see where the problem is. Running rack 1.1. Help please...


There is a Rack::File class, which has precedence in your rackup file because of the way Ruby looks up names. This is not the class you are looking for, you want Ruby's own File class. That class can be referenced directly without lookup ambiguity by using the prefix ::

::File.open('public/index.html')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜