4

Hi,

I would like to make the user be able to edit the mail content, like body, subject, etc. and in the same time, this content contains some parameters related to the user.

I used a gem called Maily https://github.com/markets/maily, which I was able to view all saved email erb templates, edit, and update them locally. Which, actually rewrite or overwrite the erb file to match the new updates.

This worked very well on development environment, while did not work on Heroku as production, because Heroku platform is using an ephemeral writing filesystem. This means that every time you deploy, restart or scale up/down the dynos in your app, you're getting a new clean filesystem based on the content of your repository, and updating templates within the app is not going to work.

So, what are alternative solutions? if you have a good gem to be used and works with heroku. Or, how can I save mail template in S3 storage and call it again when sending emails or in editing. Or, how to save the template in database model and render them again in views to be reedited or while sending the mails.

Thank you and waiting your feedback

Mohamed Sami
  • 866
  • 10
  • 22

1 Answers1

3

Or, how to save the template in database model and render them again in views to be reedited or while sending the mails.

Here's an example of how you can do this with Liquid templates: http://cjohansen.no/en/rails/liquid_email_templates_in_rails

And another example using Markdown and Devise: http://code.dblock.org/rails-custom-and-editable-mailer-templates-in-markdown

sergiopantoja
  • 475
  • 3
  • 7