0

I'm a Sinatra/Ruby n00b. How do I make Ruby recognize my own image paths?

In my haml file, I have this line:

  %img{:src => "/img/logo.png"}

But when I open the page I get a 404 error:

http://localhost:4567/img/logo.png Failed to load resource: the server responded with a status of 404 (Not Found)

1 Answers1

0

The default folder Sinatra looks into for static assetes is the public folder.

In your projects root directory create a directory called public. Inside of that create your img/logo.png path.

my_sinatra_project/app.rb  # example of file where your sinatra routes are defined
my_sinatra_project/public/img/logo.png  # where to put your static assets
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159