Using Roadie 3 With Rails 4

email, ruby, ruby-on-rails, ruby-on-rails-4

Solution

Figured it out, there's a separate gem for using Roadie 3 in Rails. They just don't mention it on the Roadie README yet. Currently it's really early alpha so you might want to wait before trying to use it.

Problem

I'm trying to use the Roadie 3 gem in a Rails 4 application and I can't figure out how to make it work. Once I add the gem to my bundle I . ``` class SuggestionMailer < ActionMailer::Base default from: "hi@app.com" def suggestions(user, suggestions) @suggestions = suggestions @stylesheets = %w[/assets/ink/base.css /assets/suggestion_mailer/suggestions.css] mail(to: user.email, subject: subject) end end ``` The stylesheets are added to the email HTML in this loop: ``` <head> <% @stylesheets.each do |href| %> <link rel="stylesheet" type="text/css" href="<%= href -%>" > <% end -%> </head> ``` It all seems to work fine in the development environment using the MailView gem. However, when I actually send my emails via SMTP or to Mailcatcher, Roadie doesn't appear to inline the stylesheets before they are sent. I'll receive an unstyled email with `<link/>` tags still intact in the `<head/>` of the email. At first I thought the issue was being caused by the fact that I'm sending my emails in a background process but the issue persists when I send them directly from the Rails console. The Roadie Readme seems more concerned with showing how to use it from outside Rails than within. How am I supposed to get Roadie 3 to work with Rails 4?

Original source