Ask A Question

Notifications

You’re 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 πŸ‘

Reply

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

Reply

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)

Reply

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.

Reply

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.

Reply
Reply
Join the discussion
Create an account Log in

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

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

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