Rack throwing an error when trying to serve a static file
Question
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...
Solution
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')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow