Rails 2.0 ActionMailer breaks my redmine render_message

13 views
Skip to first unread message

Kad Kerforn

unread,
Dec 8, 2007, 12:08:29 PM12/8/07
to rubyonra...@googlegroups.com
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
--
Posted via http://www.ruby-forum.com/.

Rick Olson

unread,
Dec 8, 2007, 1:04:56 PM12/8/07
to rubyonra...@googlegroups.com

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 Olson
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

Kad Kerforn

unread,
Dec 8, 2007, 1:45:51 PM12/8/07
to rubyonra...@googlegroups.com
Rick Olson 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...)

Marcelo Barbudas

unread,
Dec 9, 2007, 1:51:36 PM12/9/07
to rubyonra...@googlegroups.com
> 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 <us...@address.com>"
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.

Marcelo Barbudas

unread,
Dec 9, 2007, 3:14:19 PM12/9/07
to Ruby on Rails: Talk
> 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 <us...@address.com>"
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.

Jean-philippe Lang

unread,
Dec 10, 2007, 4:03:49 PM12/10/07
to rubyonra...@googlegroups.com
Kad Kerforn 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.

keeny

unread,
Jan 16, 2008, 5:31:00 PM1/16/08
to Ruby on Rails: Talk
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-
Reply all
Reply to author
Forward
0 new messages