Search code examples
ruby-on-rails-4asset-pipelinemailer

Rails 4 Mailer Images are not getting displayed


I am using roadie-rails gem for mailers. Here is my simple code to display image in mail

 <td style="padding-left:25px; padding-top:15px;">
   <%= image_tag( 'school_mailers/mail_2_logo.png' ) %>
 </td>

But when i inspect the image url in mail it is https://staging.pw/images/school_mailers/mail_2_logo.png

instead it should be https://staging.pw/assets/school_mailers/mail_2_logo-digest.png

The thing is when i send scheduled mailers using whenever gem, the mail is perfect with all images.

Does anybody have an idea about why its not displayed in other mailers?


Solution

  • The actual problem is with assets precompilation,

    I do have two servers( web and worker ). All assets have been precompiled only in web server. So 'whenever' gem sends mail from web server and delayed_job sends from worker server.

    Adding below in deploy.rb made it work

    set :assets_roles, [:web, :worker]