Bootstrap for email styling with Rails 5 in API mode

756 views Asked by At

I have a Rails 5 API app. I'd like to be able to send styled emails using Bootstrap, but after adding gem boostrap to my Gemfile and running bundle install I get this error:

 7:in `method_missing': undefined method `assets' for #Rails::Application::Configuration:0x0000555adc2497f8> (NoMethodError)

What do I have to do to so I can use the bootstrap gem in my API app?

2

There are 2 answers

0
JonesGladston On BEST ANSWER

For those still looking into this question

You will have to uncomment "require 'sprockets/railtie'" from your application.rb file.

Then add manijest.js file in 'app/assets/config/manifest.js' and link your directories in that file

//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css

For more info, you can check out the rails asset pipeline documentation

1
Jefferson Hudson On

I found a way to do this that did not involve using the bootstrap gem.

Using the premailer and premailer-rails gems I was able to inline the bootstrap styles by including a CDN link in the header of my mailer's HTML template.