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/.
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
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...)
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.
Problem is fixed in Redmine r975 (or 0.6.1).
It's now Rails 2.0 compatible.