Ruby-on-rails – How to display images outside the Ruby on Rails project directory

How to display the image, which is stored outside the project directory.
You can do two things: symbolically link a file from a public folder and provide the image as a static resource, or use File.read (/path/to/file) to read the image and use send_file to send binary data or from the control Send_data in the browser.

The first option can also be slightly modified: you can use the rails controller action to capture the image request and provide it to the browser. In addition, you can add a symbolic link , And serve the file statically since then.

I hope this helps.

How to display an image, which is stored in the project directory External.

You can do two things: symbolically link files from public folders and provide images as static resources, or use File.read(/path/ to / file) read the image and use send_file to send binary data or send_data from the controller.

The first option can also be slightly modified: you can use the rails controller operation to capture the image Request and provide it to the browser. Also, you can add a symbolic link and serve the file statically from then on.

I hope this helps.

Leave a Comment

Your email address will not be published.