Sending email with the contents in the database

Hi all,

I am implementing the functionality where I have to send an email to the
user with the contents already stored in the database. That i am able to
do but the problem is the contents stored in the database have variables
like <%= @username %> and i have to replace these variables with the
values while sending the email.
i.e I have a content called body in the database having value:
Welcome <%= @username%>.

The login and password are <%= @username %> and <%= @password%>.

Now when in notifier i write

body :contents => content

and in the view i access it
<%= @contents %>.

This sends the email with the contents with variable @username. But I
want to replace these variables with the values of username and
password.

Please let me know how to implement it.

Thanks,
Ruchita.

you can run the string manually through erb:

assuming your table/col is in eg @email.content

result = ERB.new(@email.content).result(binding)