I''m generating an XML feed to be used from outside of a Rails application. The feed should include URLs for associated images. I''m using image_path to generate the image URLs. This respects relative_url_root, but all it gives me is the absolute path of the image relative to the domain root (e.g. /image_assets/1234/ my_image.jpg). Is there a standard way to get fully specified absolute URLs to images? I looked at url_for, which implements an :only_path option, but that option is only available for controller paths. Thanks, Sven --~--~---------~--~----~------------~-------~--~----~ 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 Jan 27, 2009, at 2:53 PM, Sven wrote:> I''m generating an XML feed to be used from outside of a Rails > application. The feed should include URLs for associated images. I''m > using image_path to generate the image URLs. This respects > relative_url_root, but all it gives me is the absolute path of the > image relative to the domain root (e.g. /image_assets/1234/ > my_image.jpg). Is there a standard way to get fully specified absolute > URLs to images? I looked at url_for, which implements an :only_path > option, but that option is only available for controller paths. > > Thanks, > > SvenTry image_url rather than image_path -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 Jan 27, 3:57 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> Try image_url rather than image_pathSadly that method does not seem to exist (at least not in ActionView::Helpers::AssetTagHelper or in the Rails API docs). I wish it did! -Sven --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 27, 2009, at 4:06 PM, Sven wrote:> > On Jan 27, 3:57 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> > wrote: >> Try image_url rather than image_path > > Sadly that method does not seem to exist (at least not in > ActionView::Helpers::AssetTagHelper or in the Rails API docs). I wish > it did! > > -SvenSo write one! (or try this untested one) def image_url(source) abs_path = image_path(source) unless abs_path =~ /\Ahttp/ abs_path = "http#{''s'' if https?}://#{host_with_port}/#{abs_path}" end abs_path end Put it in a helper such as app/helpers/application_helper.rb -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---