Forum: Ruby on Rails using ActionMailer with template files retrieved from sql da

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0900e6a4828bd989f96427082c6c74ca?d=identicon&s=25 Mike Garey (random52k)
on 2006-06-01 22:10
(Received via mailing list)
I'm trying to set up a system which allows users to create and modify
emails to send out to clients.  I've got ActionMailer set up to send
from a template file stored on the file system, but I'd like to be
able to move this into the database.  Does anyone know how to get
ActionMailer to read the contents of the email from a database table
rather than the on-disk template file?  Thanks,

Mike
0a7939e3268c7c6191bc6fdb29352fed?d=identicon&s=25 Cloves Carneiro Jr (Guest)
on 2006-06-02 00:44
Hi Mike

In your class that extends ActionMailer::Base, assuming that you have a
User class and the contents of the email you want to send is in the
email_contents field, use code like this:

  @body = initialize_template_class(:user => user).render(:inline =>
user.email_contents)

Cheers,

Cloves Carneiro Jr
http://re.visioni.st

Mike Garey wrote:
> I'm trying to set up a system which allows users to create and modify
> emails to send out to clients.  I've got ActionMailer set up to send
> from a template file stored on the file system, but I'd like to be
> able to move this into the database.  Does anyone know how to get
> ActionMailer to read the contents of the email from a database table
> rather than the on-disk template file?  Thanks,
>
> Mike
A2b2f4ee23989dc68529baef9cbddcd6?d=identicon&s=25 Julian 'Julik' Tarkhanov (Guest)
on 2006-06-02 01:09
(Received via mailing list)
On 2-jun-2006, at 0:44, Cloves Carneiro Jr wrote:

> Hi Mike
>
> In your class that extends ActionMailer::Base, assuming that you
> have a
> User class and the contents of the email you want to send is in the
> email_contents field, use code like this:
>
>   @body = initialize_template_class(:user => user).render(:inline =>
> user.email_contents)

Please please wiki that.

Note to the one who asked - make sure to use Liquid or Raduis or such
because you can't allow your users to write ERB (if you care about
security)

--
Julian 'Julik' Tarkhanov
please send all personal mail to
me at julik.nl
This topic is locked and can not be replied to.