Using absolute paths for images

Hi all,

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?

Many thanks, Adam

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.

-- gw

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...

you can set a default root directory if there is only one folder for all the images outside ur rails app

but i would recommend you to put the image in the same application since if you are going to deploy that going forward..thats the right method to do..

Dhaval Parikh Software Engineer sales(AT)railshouse(DOT)com

Thanks all, symlinks worked perfectly for what I'm trying to do.