Rails 7 – How do I display images that are in a different location than my Rails app?

  Kiến thức lập trình

My Rails app resides in /Users/adam/railsapps/my_project.
The images are stored in /Users/adam/gallery/.

In the database of my Rails app, I have stored information about the images, including the path to them.

In my Rails app, when I do

[![<%= image_tag("/Users/adam/gallery/#{image.filename_path}") %>][1]][1]

the images are now displayed. Note – the path to the images in the example above is correct.

When I check the logs, I see there the following:

ActionController::RoutingError (No route matches [GET] "/Users/adam/gallery/img_name.jpg"

How do I solve this problem?

LEAVE A COMMENT