inline_attachment all fixed now

Posted by Jason King about 1 year ago

I’ve just rewritten inline_attachment to have more features, with less code, and be more reliable (ie. not as likely to break with a Rails version bump).

The coolest new feature is full support for the ActionMailer auto-multipart feature, so mostly you won’t need to write any complex MIME part crap in your model. No code is always good :)

Quickly

app/models/notifier.rb

class Notifier < ActionMailer::Base
  def signup
    recipients %q{"Testing IA" <testing@handle.it>}
    from       %q{"Mr Tester" <tester@handle.it>}
    subject "Here's a funky test"
  end
end

# Oh yeah baby!  Read it and weep!  So how's this work?  Well, you'll need
# your templates named properly - see the `Multipart email` section of the
# ActionMailer::Base docs.

signup.text.plain.erb

Your username is: <%= @username %>

signup.text.html.erb

<html>
  <head>
    <title>Signup Notification</title>
  </head>
  <body>
    <%= image_tag "logo.png" %>
    <p>Your username is: <%=h @username %>
  </body>
</html>

Obviously you also need that logo.png in your public/images directory.

…cont.