accessing files from the public directory

if I put a test.jpg file into the public/ directory, should I just be able to use it in my template with <img src="/test.jpg">?

I’ve done it in my project, but going directly to the URL results in a 404 No route found for GET /test.jpg error, so is there a configuration I’m missing or something?

Hello!

This is a default setting included in config/app.rb:slight_smile:

config.middleware.use Rack::Static, urls: ["/assets", "/uploads"], root: "public"

This tells Rack::Static that it can only serve files from public/assets or public/uploads.

If you want to include test.jpg in there, you can add it in:

config.middleware.use Rack::Static, urls: ["/assets", "/uploads", "/test.jpg"], root: "public"

Or if you want to open up public to the world:

config.middleware.use Rack::Static, urls: [""], root: "public", cascade: true