All threads / Editable emails templates

Ask A Question

Notifications

You鈥檙e not receiving notifications from this thread.

Editable emails templates

Karim Tarek asked in Rails

Hi there 馃憢
I need users to be able to edit email templates, something like:
Hello {{ first_name }},
Please advice, thanks 馃憤

This is a pretty large project :) I assume you want a model called email_templates. Then I think you want a "rich_text_field" with name body_html (or similar). Then you will want to use something like the liquid templating language to parse and replace {{ variable_name }} when rendering said template.

Resources

If you are just letting them change a few things like the subject, maybe disclaimer text, etc you can probably get by with a user_email_templates table with columns that map to those variables. Then when you go to send the email...simply load the template and inject the variables (with erb)

Thanks Casey 馃憤
Those are the same resources that I manged to find. They are outdated so I thought maybe there are newer resources I'm not able to find, for example "effective_email_templates" gem is no longer maintained.

You are most welcome. The resources I listed are not recommendations to install and use :) They are reference material so you can see examples of how others have done similar tasks concretely and with documentation. The idea being if you need to rebuild all or a portion of those solutions you have some pretty solid inspiration.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.