Mange / roadie-rails

Making HTML emails comfortable for the Rails rockstars
MIT License
367 stars 66 forks source link

Defining external_asset_provider for Stylesheets #55

Closed regularlady closed 8 years ago

regularlady commented 8 years ago

@Mange thank you so much for making such a great gem.

A quick question for you: how would you define Amazon s3 as the external_asset_provider for hosted email stylesheets? I hunted around both roadie-rails and roadie and did not find the correct syntax for s3. We tried setting the external_asset_provider in the mail block below but did not have any luck.

Our email is built like this:

  class UserMailer < ActionMailer::Base
    include Roadie::Rails::Automatic
    layout "email"

    def self.branded_email_css
      "//awsbucket.s3.amazonaws.com/production/assets/branding/email"
    end

    def registration_confirmation_mail(user)
      @user = user

      mail({
               to: @user.email,
               from: "donotreply@hello.org",
               subject: "Welcome!",
               date: Time.now,
               content_type: "text/html",
               css: UserMailer.branded_email_css
           })
    end

  end

Thanks for your advice!

Mange commented 8 years ago

Hi,

Thank you for your kind words!

The style of passing css as an option to mail is no longer used in Roadie 3, and Roadie 2 could only access from the local file system.

Which version are you on?

ons 24 feb. 2016 21:38 Brittany Martin notifications@github.com skrev:

@Mange https://github.com/Mange thank you so much for making such a great gem.

A quick question for you: how would you define Amazon s3 as the external_asset_provider for hosted email stylesheets? I hunted around both roadie-rails and roadie and did not find the correct syntax for s3. We tried setting the external_asset_provider in the mail block below but did not have any luck.

Our email is built like this:

class UserMailer < ActionMailer::Base include Roadie::Rails::Automatic layout "email"

def self.branded_email_css
  "//awsbucket.s3.amazonaws.com/production/assets/branding/email"
end

def registration_confirmation_mail(user)
  @user = user

  mail({
           to: @user.email,
           from: "donotreply@hello.org",
           subject: "Welcome!",
           date: Time.now,
           content_type: "text/html",
           css: UserMailer.branded_email_css
       })
end

end

Thanks for your advice!

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

regularlady commented 8 years ago

Hi @Mange,

I'm using roadie-rails version 1.0.6 which depends on roadie 3.1.1. Does this mean we need to define our styles in-line? Thanks again for your response!

Mange commented 8 years ago

Yes, that's correct. If you look at the documentation for Roadie, you'll see how it works. Roadie-rails should allow you to use Rails' normal asset helpers.

If you need to download the assets, you can use an external_provider as documented in Roadie, although you set it on roadie_options in your Rails app.

Let me know if you need any code examples.

fre 26 feb. 2016 14:28 Brittany Martin notifications@github.com skrev:

Hi @Mange https://github.com/Mange,

I'm using roadie-rails version 1.0.6 which depends on roadie 3.1.1. Does this mean we need to define our styles in-line? Thanks again for your response!

  • Britt

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

regularlady commented 8 years ago

Thanks! Will re-open if I need more help.