Why would I get “Errno::ENOENT: No such file or directory” when viewing a Sinatra form?

こ雲淡風輕ζ 提交于 2019-12-06 09:43:55

If you cannot get shotgun to work then the new recommended way to reload Sinatra seems to be rerun.

To use it:

> gem install rerun
> cd /Users/HelenasMac/Desktop/RubyForm
> rerun ruby basics.rb

Explicity Set a Views Directory

Unless you're using inline template for your views with enable :inline_templates, you may need to explicitly define a template directory if the default values aren't working for you. The docs describe how to set your views directory as follows:

:views - view template directory

A string specifying the directory where view templates are located. By default, this is assumed to be a directory named “views” within the application’s root directory (see the :root setting). The best way to specify an alternative directory name within the root of the application is to use a deferred value that references the :root setting:

set :views, Proc.new { File.join(root, "templates") }

You may also need to explicitly set :root, and make sure that both :root and :views make sense from your current working directory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!