首页 > 解决方案 > Rails image doesn't show up in mailers

问题描述

I send 2 types of e-mails in my application: welcome mailer, reset password mailer. I need to have the same logo at the top of each of them. I thought it will be easy job to do but unfortunately the logo seems to be brokencheck-here. Here is my for welcome mailer code:

views/devise/layouts/devise_mailer.html.erb

  <body>
    <div class="container">
      <%= image_tag("logo.png", class: 'logo', align: :center) %>
          <%= yield %>
    </div>
  </body>

Based on docs I've added asset_host to the config file https://edgeguides.rubyonrails.org/action_mailer_basics.html#adding-images-in-action-mailer-views

config/development.rb

config.action_mailer.asset_host = 'localhost:3000'

The logo itself is in app/assets/images/logo.png.

标签: htmlruby-on-railsruby

解决方案


推荐阅读