开发者

Rack throwing an error when trying to serve a static file

开发者 https://www.devze.com 2022-12-24 14:57 出处:网络
use Rack::Static, :urls => [\'/stylesheets\', \'/images\'], :root => \'public\' run proc { |env| [200, { \'Content-Type\' => \'text/html\', \'Cache-Control\' => \'public, max-age=86400\'
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

精彩评论

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