# Rails 2.0 ActionMailer breaks my redmine render\_message

**URL:** <https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518>\
**Category:** Rails\
**Created:** [December 8, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518 "2007-12-08T18:08:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [December 8, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/1 "2007-12-08T18:08:29Z")

</div>

I am using ‘redmine’ (v 0.6) as my major project manager, seems running  
fine w Rails 2.0 (slight modifs for paginations…) but I am stuck with a  
major error when sending a confirmation email :

mailer.rb  
class Mailer \< ActionMailer::Base  
…

# Renders a message with the corresponding layout

def render\_message(method\_name, body)  
layout = method\_name.match(%r{text.html.(rhtml|rxml)}) ?  
‘layout.text.html.rhtml’ : ‘layout.text.plain.rhtml’  
body[:content\_for\_layout] = render(:file =\> method\_name, :body =\>  
body)  
ActionView::Base.new(File.join(template\_root, ‘mailer’), body,  
self).render(:file =\> layout)  
end  
end

the last line is not accepted when running rails 2.0 =\> ERROR  
ActionView::ActionViewError (Due to changes in ActionMailer, you need to  
provide the mailer\_name along with the template name.  
render “user\_mailer/signup”  
render :file =\> “user\_mailer/signup”  
If you are rendering a subtemplate, you must now use controller-like  
partial syntax:  
render :partial =\> ‘signup’ # no mailer\_name necessary)

in debugging mode, I got :

File.join(template\_root, ‘mailer’) =\> 'my\_redmine\_path/app/views/mailer  
layout =\> “layout.text.html.rhtml”  
body =\> { … :url … ::content\_for\_layout… , :token… } seems OK

I don’t know how to render correctly as rails 2.0 ActionMailer seems to  
expect it …  
any patch ?

thanks for your help

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [December 8, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/2 "2007-12-08T19:05:47Z")

</div>

On 12/8/07, Kad K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ?
> 
> ```
> 
> provide the mailer\_name along with the template name.  
> body =\> { … :url … ::content\_for\_layout… , :token… } seems OK
> 
> I don’t know how to render correctly as rails 2.0 ActionMailer seems to  
> expect it …  
> any patch ?
> 
> thanks for your help

As the exception message states, you now need to provide the mailer  
name along with the template name. Sorry for the change in 2.0, but  
this makes ActionMailer a little more consistent with ActionPack as  
far as rendering goes. I believe this is the line that’s causing you  
issues:

body[:content\_for\_layout] = render(:file =\> method\_name, :body =\>  
body)

method\_name is no longer sufficient, you’ll need the mailer name too.  
Maybe “#{mailer\_name}/#{method\_name}” ? I don’t use redmine so I  
wouldn’t know.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [December 8, 2007, 7:45pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/3 "2007-12-08T19:45:51Z")

</div>

Rick O. wrote:  
As the exception message states, you now need to provide the mailer

> name along with the template name. Sorry for the change in 2.0, but  
> this makes ActionMailer a little more consistent with ActionPack as  
> far as rendering goes. I believe this is the line that’s causing you  
> issues:
> 
> body[:content\_for\_layout] = render(:file =\> method\_name, :body =\>  
> body)
> 
> method\_name is no longer sufficient, you’ll need the mailer name too.  
> Maybe “#{mailer\_name}/#{method\_name}” ? I don’t use redmine so I  
> wouldn’t know.

Thanks Rick,

I tried, but it’s not it… I’am going to give up from redmine for a  
while, until it will the developers test it w 2.0… back to Trac !  
this render\_message is specific to redmine and take precedence over  
ActionMailer base render\_message  
so I don’t actually understand how this line is performing and for what  
purpose , im my own dev, I tsick to standard rails mailer actions… and  
it works… they tried to be smart, but too smart maybe for 2.0

ActionView::Base.new(File.join(template\_root, ‘mailer’), body,  
self).render(:file =\> layout)

File.join(template\_root, ‘mailer’) this is the full path to the mailer  
views : “…/redmine/app/views/mailer”

ActionView::Base.new(“the\_views\_mailer\_path”, body, self)  
creates an ActionView::Base  
THIS I don’t understand very well… as I could not grab the  
description of ActionView::Base.new  
(too indepth for my present level of rails knowledge)

this new ActionView::Base is rendered with a layout…(:file =\> layout)

this is the problem… (I run a breakpoint at this line…)

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [December 9, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/4 "2007-12-09T19:52:15Z")

</div>

> the last line is not accepted when running rails 2.0 =\> ERROR  
> ActionView::ActionViewError (Due to changes in ActionMailer, you need to  
> provide the mailer\_name along with the template name.  
> render “user\_mailer/signup”  
> render :file =\> “user\_mailer/signup”  
> If you are rendering a subtemplate, you must now use controller-like  
> partial syntax:  
> render :partial =\> ‘signup’ # no mailer\_name necessary)

I get the same error but I am not using redmine.

This is the function:  
def signup\_notification(user)  
recipients user.email  
from “From [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”  
subject ‘Please activate your new account’  
body :url =\> “activation\_url”, :user =\> user  
end

If I add:  
render “user\_notifier/signup\_notification”  
it returns:  
can’t convert Symbol into String

If I add  
render :file =\> “user\_notifier/signup\_notification”  
it returns:  
Couldn’t find template file for user\_notifier/signup\_notification in  
“/path/app/views/user\_notifier”

–  
M.

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [December 9, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/5 "2007-12-09T21:14:26Z")

</div>

> the last line is not accepted when running rails 2.0 =\> ERROR  
> ActionView::ActionViewError (Due to changes in ActionMailer, you need to  
> provide the mailer\_name along with the template name.  
> render “user\_mailer/signup”  
> render :file =\> “user\_mailer/signup”  
> If you are rendering a subtemplate, you must now use controller-like  
> partial syntax:  
> render :partial =\> ‘signup’ # no mailer\_name necessary)

> 

I get the same error but I am not using redmine.

This is the function:  
def signup\_notification(user)  
recipients user.email  
from “From [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”  
subject ‘Please activate your new account’  
body :url =\> “activation\_url”, :user =\> user  
end

If I add:  
render “user\_notifier/signup\_notification”  
it returns:  
can’t convert Symbol into String

If I add  
render :file =\> “user\_notifier/signup\_notification”  
it returns:  
Couldn’t find template file for user\_notifier/signup\_notification in “/  
path/app/views/user\_notifier”

–  
M.

P.S. Sorry if this email arrives twice.

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [January 16, 2008, 11:32pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/6 "2008-01-16T23:32:07Z")

</div>

I got the same problem using Acts As Authenticated plugin. I don’t  
know the reason why, but when I commented out the following line in  
config/environment.rb, ActionMailer stopped complaining.

# RAILS\_GEM\_VERSION = ‘2.0.2’ unless defined? RAILS\_GEM\_VERSION

On Dec 10 2007, 9:03 pm, Jean-philippe Lang \<rails-mailing-

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [December 10, 2007, 10:03pm UTC](https://www.ruby-forum.com/t/rails-2-0-actionmailer-breaks-my-redmine-render-message/122518/7 "2007-12-10T22:03:49Z")

</div>

Kad K. wrote:

> I am using ‘redmine’ (v 0.6) as my major project manager, seems running  
> fine w Rails 2.0 (slight modifs for paginations…) but I am stuck with a  
> major error when sending a confirmation email

Problem is fixed in Redmine r975 (or 0.6.1).  
It’s now Rails 2.0 compatible.
