# Help for ActionMailer!

**URL:** <https://www.ruby-forum.com/t/help-for-actionmailer/160181>\
**Category:** Rails\
**Created:** [February 12, 2009, 4:59pm UTC](https://www.ruby-forum.com/t/help-for-actionmailer/160181 "2009-02-12T16:59:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaus.kohlbauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@klaus.kohlbauer](https://www.ruby-forum.com/u/klaus.kohlbauer)\
**Post date:** [February 12, 2009, 4:59pm UTC](https://www.ruby-forum.com/t/help-for-actionmailer/160181/1 "2009-02-12T16:59:32Z")

</div>

Hello,

I have a big problem und hoping for your help.

In my application a user should be able to edit an email template file  
for himself and send it out e.g. to a customer. (thats the plan).

For that I have created some functionality to edit the template file  
and an ActionMailer class with a method called ‘createMail’. The user  
is editing the template file, saves the file and then he is sending  
the mail to the customer. Thats working fine. But now the user is  
making changes on the template file and he wants to send it out  
again. And now my problem comes up. The result of createMail() is the  
same as it was for the first time. The changes, the user has made in  
the template file are not in the created email.

I think that has something to do with caching. Because all is working  
well in the development environment but not in production.

Is there anyone who can help. Is there a possibility to force the  
system to use the newer version of the template file and not to be  
‘proud’ of an old file.

If I can get any help you will get an invitation to the octoberfest in  
munich/bavaria/germany later this year 🙂

Best regards  
Klaus Kohlbauer

infosense gmbh  
Infanteriestrasse 19/5  
80797 München  
Telefon Büro: +49 89 12 11 35 59  
Telefon Mobil: +49 173 999 777 9  
Email: removed\_email\_address@domain.invalid  
Web: [www.infosense.de](http://www.infosense.de)

---

<div class="post-metadata">

**Author:** ![klaus.kohlbauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@klaus.kohlbauer](https://www.ruby-forum.com/u/klaus.kohlbauer)\
**Post date:** [February 12, 2009, 5:04pm UTC](https://www.ruby-forum.com/t/help-for-actionmailer/160181/2 "2009-02-12T17:04:49Z")

</div>

On Feb 12, 3:18 pm, “klaus.kohlbauer” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> the mail to the customer. Thats working fine. But now the user is  
> making changes on the template file and he wants to send it out  
> again. And now my problem comes up. The result of createMail() is the  
> same as it was for the first time. The changes, the user has made in  
> the template file are not in the created email.
> 
> I think that has something to do with caching. Because all is working  
> well in the development environment but not in production.

You might be interested in  
[http://groups.google.com/group/rubyonrails-core/browse\_thread/thread/1119127159435e5c](http://groups.google.com/group/rubyonrails-core/browse_thread/thread/1119127159435e5c)  
They’re talking about actioncontroller views rather than actionmailer  
views but it’s all the same really.

What I’ve done in the past is just sidestep this completely with a  
mailer method like this:

def standard\_email(recipient, template)  
setup\_common(recipient)  
@subject = template.subject  
@body = Liquid::Template.parse(template.body).render({})  
end

template is an activerecord object holding the body, subject etc. of  
the message. I happened to use Liquid to render the message, but  
that’s up to you. You could read templates from disk rather than from  
database.

Fred

---

<div class="post-metadata">

**Author:** ![klaus.kohlbauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@klaus.kohlbauer](https://www.ruby-forum.com/u/klaus.kohlbauer)\
**Post date:** [February 13, 2009, 9:12am UTC](https://www.ruby-forum.com/t/help-for-actionmailer/160181/3 "2009-02-13T09:12:41Z")

</div>

Sound good - I will try it. Thanks.  
Klaus Kohlbauer

On 12 Feb., 17:04, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
