Rails 2.0 ActionMailer breaks my redmine render_message

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

On 12/8/07, Kad K. [email protected] 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://weblog.techno-weenie.net
http://mephistoblog.com

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…)

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 [email protected]
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.

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 [email protected]
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.

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-

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs