Mange / roadie-rails

Making HTML emails comfortable for the Rails rockstars
MIT License
363 stars 65 forks source link

Roadie does not support asset_url #31

Closed gabeodess closed 9 years ago

gabeodess commented 9 years ago

In my email template

asset_url('logo.png')

gets rendered as

'/assets/logo.png'

When I would like it to be rendered as

'http://localhost:3000/assets/logo.png'

as it does when I use image_tag.

Instead I find I need to do the following:

<table>
<tr>
  <td background="<%= URI.parse(asset_url('logo.png')).tap{ |uri| ActionMailer::Base.default_url_options.each{ |k,v| uri.send("#{k}=", v) } }.to_s %>">
  </td>
</tr>
</table>

Seems like a no-brainer... am I missing something?

Please advise!

Mange commented 9 years ago

Roadie does not pick up the background attribute. It only picks up a[href] and img[src]. If you changed this into a style attribute, Roadie will properly handle it:

<td style="background: url(&quot;<%= asset_url('logo.png') %>&quot;);">
  ...
</td>
gabeodess commented 9 years ago

Ah, so Roadie does a post processing on the document itself as opposed to overriding the url helpers. Got it, thanks.

On a side note, I had to disable the url_options for Roadie because it was throwing an "invalid url' error for my unsubscribe link. The issue is that Mandrill uses a token that is not a proper URL but instead gets replaced once the email hits their SMTP server. Is there any way around this with Roadie or do I just have to completely turn off the url_options?

Mange commented 9 years ago

There's a closed issue about Mandrill links in roadie-rails, or the roadie repo. See if you can find it; I'm on my phone and unable to look it up right now.

tis 3 feb 2015 16:28 Gabe Odess notifications@github.com skrev:

Ah, so Roadie does a post processing on the document itself as opposed to overriding the url helpers. Got it, thanks.

On a side note, I had to disable the url_options for Roadie because it was throwing an "invalid url' error for my unsubscribe link. The issue is that Mandrill uses a token that is not a proper URL but instead gets replaced once the email hits their SMTP server. Is there any way around this with Roadie or do I just have to completely turn off the url_options?

— Reply to this email directly or view it on GitHub https://github.com/Mange/roadie-rails/issues/31#issuecomment-72670016.