Hi, I am building a rails app which supports accounts based on subdomain names. I want to serve files in public with respect to the subdomain name. For example: url: foo.myapp.com <img src="images/bar.jpg"> should deliver public/foo/images/bar.jpg. Is there any way to do this in rails? Or should I use the Mongrel::HttpHandler and response.send_data? Regards Adam -- 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 -~----------~----~----~----~------~----~------~--~---
On 25 Feb 2008, at 10:26, Adam Groves wrote:> I am building a rails app which supports accounts based on subdomain > names. I want to serve files in public with respect to the subdomain > name. For example: > > url: foo.myapp.com > <img src="images/bar.jpg"> should deliver public/foo/images/bar.jpg. > > Is there any way to do this in rails? Or should I use the > Mongrel::HttpHandler and response.send_data?Using the account_location plugin, something like this should work: image_tag("/#{account_subdomain}/images/#{picture_name}") Although I would advise you to create a separate folder in public to store all your user images, otherwise your public folder will become a huge collection of folders pertaining to rails and your customers. Hard to keep track of them and back them up efficiently and you''ll have serious problems if you deploy via capistrano if you use your method. Something like /public/user_images/subdomain/image.jpg would be more appropriate. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 for the reply Peter. I should have been clearer in my post: the idea is that users will be able to add content via Textile, meaning that Rails helpers will not be used for generating image or link paths. -- 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 -~----------~----~----~----~------~----~------~--~---
On 25 Feb 2008, at 11:07, Adam Groves wrote:> Thanks for the reply Peter. I should have been clearer in my post: the > idea is that users will be able to add content via Textile, meaning > that > Rails helpers will not be used for generating image or link paths.Then how are you going to solve your problem of displaying images? I''ve done something quite similar to what you have done, and this is my setup: - Allow user to upload a collection of images (uses attachment_fu), I''ve added the ability to shove them into albums and add some searchable tags to it - Below my textarea (using Textile) they can browse through their images, select one and then click the "Insert" button. This could insert the correct the !image_url! text into the textarea. I''ve done it a bit differently and have added my own tag parsing method (I don''t remember it too well, it''s an old project), something like &my_image.jpg& so that the user doesn''t even see this is translated to /user_images/subdomain/my_image.jpg when saving the record. And my comment on having to be able to easily symlink the folder containing the user images when deploying via capistrano still stands. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
if you need moreour control, set up mod_xsendfile and keep images outside of public there should be plugin, to make it even easier On 25 фев, 11:26, Adam Groves <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I am building a rails app which supports accounts based on subdomain > names. I want to serve files in public with respect to the subdomain > name. For example: > > url: foo.myapp.com > <img src="images/bar.jpg"> should deliver public/foo/images/bar.jpg. > > Is there any way to do this in rails? Or should I use the > Mongrel::HttpHandler and response.send_data? > > Regards > > Adam > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---