Hey,

I am sending out html emails. It seems to me that in order for the
images to be properly shown in the email, their src needs to be
absolute.

More precisely, /images/email/header.gif will not work, but
http://localhost:3000/images/email/header.gif will. (If someone can
refute me here, I am eager to hear it). So I was looking to use the
image_tag helper to get the absolute url for the image source but I
could not figure out a solution. So what I am currently doing is this:

class UserMailer < ActionMailer::Base
    def setup_email(user)
      (...)
      url_with_host = url_for(:controller => "home", :action =>
"index", :only_path => false)
      host_pattern = /^(.*:\/\/.+?)\/.*$/
      @body[:http_host] = url_with_host[host_pattern, 1]
      content_type "text/html"

    end
end

(setup_email is then called from the actual mailer methods)

But this is a hack and it supposes that there is a "home" controller.
Having the image_tag helper accept the :only_path parameter would be a
nice solution. I am curious to find out how others deal with this
problem since it does not seem to be so particular.

Thank you,
Balint
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to