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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 11, 2008, at 4:00 PM, Adam wrote:> 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: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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 www.railshouse.com sales(AT)railshouse(DOT)com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks all, symlinks worked perfectly for what I''m trying to do. On 12 Jun, 07:14, Dhaval Parikh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 Engineerwww.railshouse.com > sales(AT)railshouse(DOT)com > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---