The rack throws an error while 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 a private `open 'method called for Rack :: File: Class when I run. I don’t really see where the problem is. Running rack 1.1. Help me please...

+3
source share
1 answer

There is a class Rack::Filethat takes precedence in your registry file because of how Ruby searches for names. This is not the class you are looking for, you need a Ruby class File. This class can be directly referenced without search ambiguity using the prefix::

::File.open('public/index.html')
+3
source

Source: https://habr.com/ru/post/1737798/


All Articles