I want to make images stored on my filesystem available to a Rails
app, even if they are outside the Rails directory. For example, if my
app is in /home/adam/rails_app/my_app I want to display an image from /
home/adam/Pictures without having to copy the picture into the app
public/images directory. When I try this, using the absolute path of
the file, I get a routing error:
ActionController::RoutingError (No route matches "/home/adam/Pictures/
my_pic.jpg" with {:method=>:get})
This is using image_tag with an absolute file path "/home/adam/
Pictures/my_pic.jpg". Even if I use a simple HTML img tag, the image
is not displayed. Is it possible to bypass Rails routing and get
access to these files?
I use symbolic links to similarly deal with download files. I don't want the downloads to be part of the Rails project, so they're managed separately under another path. To make them available to Rails, I put a symbolic link in the /public folder. Your deploymemt script can deal with refreshing the symbolic link each time the app is updated/redeployed.
A solution would be apache frontend and using Alias
Alias /my_images /this/is/the/images/directory
<Directory "/this/is/the/images/directory">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
This will remove the image handling from rails and let apache do what
apache does...