Mike Garey
2006-Jun-01 20:08 UTC
[Rails] using ActionMailer with template files retrieved from sql database table instead of on disk files
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
Cloves Carneiro Jr
2006-Jun-01 22:45 UTC
[Rails] Re: using ActionMailer with template files retrieved from sq
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-- Posted via http://www.ruby-forum.com/.
Julian ''Julik'' Tarkhanov
2006-Jun-01 23:08 UTC
[Rails] Re: using ActionMailer with template files retrieved from sq
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