In Beer Veritas

  • Archive
  • RSS
  • Ask me anything

Render Devise Emails in Email Layout

Thought I’d share this solution as my Googling didn’t result in any hits. If you’re using Devise for authentication in your Ruby on Rails app and have a general HTML template that you want all emails to render in, there’s an easy way to get the default devise emails to also render in it. 

Just create a partial with all the code for the email including the <%= yield %> tag, let’s call it _email_content.html.erb.

Then create a new file in:

layouts > devise (make this folder if it doesn't exist) > mailer.html.erb

In this file (and your default template file) render your partial:

 <%= render "layouts/email_content" %>

There you go. You can still manage your email template from a single location.

    • #ruby on rails
    • #programming
    • #code
    • #hacking
    • #devise
  • 1 year ago
  • 46
  • Comments
  • Permalink
  • Share
    Tweet

46 Notes/ Hide

  1. alexanderok59 likes this
  2. odonnellui781 likes this
  3. heatheryi982 likes this
  4. salvador7dr likes this
  5. userxs78 likes this
  6. nickthejam likes this
  7. travisjtodd posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Avatar Blog from the co-founder of Toa.st, Buddy Beers and Silicon Allee, American expat in Germany, Ruby on Rails developer and beer enthusiast

Pages

  • Toast
  • Buddy Beers
  • Silicon Allee

Me, Elsewhere

  • travisjtodd on Dribbble
  • @travisjtodd on Twitter
  • Facebook Profile
  • travisjtodd on Soundcloud
  • travisjtodd on Foursquare
  • travisjtodd on github

Twitter

loading tweets…

Following

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr