I want to allow users to create mail templates through an administration
page. I store the email body as text in the database, and now I want to
take the string, and treat it like an email template and send as mail.
So for instance, if something like this is in the database:
<code>
email_templates
id | text
1 | Hello [EMAIL PROTECTED] This is an email
...
</code>
Then I'd like to do this:
<code>
template = EmailTemplate.find(1)
user = User.find(1)
MyMailer.deliver_some_mail(template.text, user)
</code>
...and
<code>
class MyMailer < ActionMailer::Base
def some_mail(template, user)
subject "..."
recipient "[EMAIL PROTECTED]"
# ...
body string_template(template, :user => user)
end
end
</code>
Is it possible? If so, how?
--
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---