app/controllers/app.rb
require 'sinatra'
get '/' do
erb :index
end
app/views/index.erb
<html>
<body>
<p>Hello World</p>
</body>
</html>
Error:
Errno::ENOENT at /
No such file or directory - .../app/controllers/views/index.erb
How do I configure erb to look into app/views instead of app/controllers/views?
You can achieve this by adjusting the configuration settings. Since you are using non-standard settings, you need to tell Sinatra what the actual root of your app is and where to find the views. At the top of your
app/controllers/app.rbfile add:You can read more about Sinatra configuration options in the Sinatra Documentation.