Nothing renders from within Rails
Closed this issue · 2 comments
Whatever I do MJML-s won't render from Rails.
Ruby 2.3.0
Rails 4.2.4
MJML 3.3.0
mjml-rails 2.4.1
My mailer:
# app/mailers/message_mailer.rb
class MessageMailer < ActionMailer::Base
def new_message
@message = message
mail(to: 'test@example.com', subject: 'test') do |format|
format.mjml
end
end
end
My view:
# app/views/message_mailer/new_message.mjml
<mjml>
<mj-body>
<mj-container>
<mj-section>
<mj-column>
</mj-column>
</mj-section>
</mj-container>
</mj-body>
</mjml>
In the console I go:
2.3.0 :001 > MessageMailer.new_message.deliver_now
I, [2017-03-28T09:37:52.228263 #671] INFO -- : Rendered message_mailer/new_message.mjml (1090.0ms)
D, [2017-03-28T09:37:52.389439 #671] DEBUG -- :
MessageMailer#new_message: processed outbound mail in 1261.5ms
I, [2017-03-28T09:37:52.397568 #671] INFO -- :
Sent mail to test@example.com (7.4ms)
D, [2017-03-28T09:37:52.398016 #671] DEBUG -- : Date: Tue, 28 Mar 2017 09:37:52 -0400
To: test@example.com
Message-ID: <58da6730606d4_29f82b0e07692f@kitsched.mail>
Subject: test
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
=> #<Mail::Message:58501260, Multipart: false, Headers: <Date: Tue, 28 Mar 2017 09:37:52 -0400>, <To: test@example.com>, <Message-ID: <58da6730606d4_29f82b0e07692f@kitsched.mail>>, <Subject: test>, <Mime-Version: 1.0>, <Content-Type: text/html>, <Content-Transfer-Encoding: 7bit>>
As you can see the HTML output doesn't appear.
If from the command line I do:
mjml -s app/views/message_mailer/new_message.mjml
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
[ snip ]
It renders the HTML without problems.
I'm out of ideas.
OK, solved it myself. Cloned the gem, ran the tests of which 4 failed, uncommented the puts with the mjml command that is run and drilled it down to something like:
# mjml -r test.mjml
Error: EISDIR: illegal operation on a directory, open './/'
at Error (native)
Which I found to be an error related to my Node.js version. I incorrectly assumed from this tutorial that all is OK with Node.js 5. Turns out it wasn't, you need at least version 6.
@kitsched ah yes - I just found out through a breaking Jenkins test that it was using Node.js 5, and so I upgraded to Node.js 7 and that seemed to fix that too.