Undefined method `mime_type` in Mailer view when using attachments

I created a mailer in my Rails 4 application that works great when there are no email attachments. However, when I add the PDF attachment for emails, I get the following error when I try to preview the email ... / rails / mailers / donor _mailer / thankyou_mail_preview

NoMethodError in Rails::Mailers#preview

Showing /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/railties-4.1.6/lib/rails/templates/rails/mailers/email.html.erb where line #95 raised:

<iframe seamless name="messageBody" src="?part=<%= Rack::Utils.escape(@part.mime_type) %>"></iframe>

      

However, I don't get this error or any problems at all when sending the emails themselves, only with the preview. Has anyone else experienced this and knows how to fix it / knows the direction I should be going. Could this lead to further problems with my email, or is it just a problem with the preview function?

My Mailer looks like this:

class DonorMailer < ActionMailer::Base

  default from: "user@gmail.com"

  def thankyou_email(computer)
    @computer  = computer
    @donor = computer.donor

    attachments["some.pdf"] = File.read("path/to/pdf/some.pdf")
    mail(to: @donor.donor_email, subject: "Thank you")
  end

end

      

and the template:

<!DOCTYPE html>
<html>
  <head>
     <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  </head>

  <body>

    <p>Email content here</p>

  </body>
</html>

      

I tried adding: pdf to my MIME types to no avail.

thank

+3
mime-types ruby-on-rails ruby-on-rails-4 email-attachments actionmailer


source to share


No one has answered this question yet

Check out similar questions:

21
Rails 3 ActionMailer and Wicked_PDF
6
Rails 4 View Mailer View Attached Images
2
Rails 4, ActionMailer & Wicked PDF
1
Using ActionMailer RoR Templates with Sendgrid v3 API
1
What to use content_type - Getting No Boundary error on Mandrill-api gem (Rails 4.1)
1
ActionMailer 2.3.5 changes my zip app
1
render pdf using shrimp as actionmailer app
1
Internal server error: undefined method "symbolize_keys" for # <string: 0x0000000589bde0>
0
Rails 5.0.1 - ActionMailer with MailGun, setting "noname" for filename on direct connection base64 string
-2
Rails server (Spreecommerce - Thin) won't start



All Articles
Loading...
X
Show
Funny
Dev
Pics