There is something strange about the Rails configuration. According to the documentation, asset_host
supposed to host only the host
part ('yoursite.com'). I decided with an assistant:
module EmailsHelper def email_image_tag(src) protocol = ActionMailer::Base.default_url_options[:protocol] || 'http' image_tag asset_path(src, protocol: protocol) end end
Set it up in your email program:
class EmailNotificationsMailer < ActionMailer::Base add_template_helper(EmailsHelper) ... end
There is no way to force image_tag to use a URL other than passing the URL to it.
source share