Rails 3.1 Assets in ActionMailer with image_tag
Assets are working fine for my web views, but for some reason my Mailer doesn't use the asset pipeline. I am trying to use an image_tag in my mailer view:
=link_t开发者_开发知识库o image_tag("logo.png")
However, that renders as
<img alt="logo" src="http://mydomain.com/assets/logo.png">
instead of
<img alt="logo" src="http://mydomain.com/assets/logo-xxxxxxxxx...png">
Am I missing something here?
My settings are:
config.action_mailer.default_url_options = { :host => config.domain }
config.action_mailer.asset_host = "http://" + config.domain
Thank you!
Try to put in your mail template the following instead of the link_to ( the link_to makes no sense because you link here your image to nothing, and I don't see the a href as output in your html) :
= asset_path("logo.png")
also put in your specific environment file :
config.action_mailer.default :content_type => "text/html"
Like this you are sure that you always use HTML as default content type. If u are using images in the mails it is better to put it as html.
精彩评论