I''m making a CRM-like system, and I would like to enable users the
ability to define and send out custom emails based on a template.
I used the method outlined here:
http://www.jonathansng.com/ruby-on-rails/rails-send-email-tutorial/
class Postoffice < ActionMailer::Base
def welcome(name, email)
@recipients = "jon-8E1Brbw1/71Wk0Htik3J/w@public.gmane.org"
@from = params[:contact][:email]
headers "Reply-to" => "#{email}"
@subject = "Welcome to Add Three"
@sent_on = Time.now
@content_type = "text/html"
body[:name] = name
body[:email] = email
end
end
where you define a new def for each email template you wish to send out
and then send the mail using
Postoffice.deliver_welcome(@user.name, @user.email)
The problem is it requires the template, in this case
welcome.text.html.erb, to be defined within the actual controller code
(because to deliver you need to use Postoffice.deliver_<template name>).
I''d like for the CRM user to be able to define a template to use, I was
planning on using an activerecord to store the actual file where as
Emailtemplate.file could specify which actionmailer view to use, however
I''m having trouble getting the mailer_name() function to work.
mailer_name() is suppose to be able to specify which template to use and
override the default. However I''m not able to find a specific example
of
how it should be used. Could anyone provide one?
Another option I thought of was storing the template in the Database and
passing the body as an argument to deliver_welcome, but I''d like to be
able to use the template system of .erb. I''d really appreciate any
suggestions fellow members could provide
--matt
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---