Problems creating emails using ActionMailer

Hi Guys,

I am having some issues with ActionMailer in a new project I am
working on.
I am getting the following message:
"Due to changes in ActionMailer you need to provide the mailer_name as
well as the template name"
That seemed simple enough, but it doesn't work.

The problem I see is similar to this:
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/517ff90aa97a11a2/b89fef43b89c3e51?lnk=gst&q=render_message#b89fef43b89c3e51

I am also using Acts_As_Authenticated.
I have tried commenting out the rails_gem_version as suggested in the
above post.

When I create an email using
body "some text goes here"
I get the email fine.

So I tried to render the email using:
render "user_notifier/signup_notification"
I get the following error
can't convert Symbol into String

*************trace log*************
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:498:in `delete'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:498:in `render'
app/models/user_notifier.rb:7:in `signup_notification'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:410:in `__send__'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:410:in `create!'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:403:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:352:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:352:in `method_missing'
app/models/user_observer.rb:5:in `after_create'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
observer.rb:157:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
observer.rb:157:in `update'
c:/ruby/lib/ruby/1.8/observer.rb:185:in `notify_observers'
c:/ruby/lib/ruby/1.8/observer.rb:184:in `each'
c:/ruby/lib/ruby/1.8/observer.rb:184:in `notify_observers'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:338:in `notify'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:302:in `callback'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:227:in `create_without_timestamps'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
timestamp.rb:29:in `create'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:2238:in `create_or_update_without_callbacks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:213:in `create_or_update'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1972:in `save_without_validation'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
validations.rb:934:in `save_without_transactions'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in `save'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/database_statements.rb:66:in
`transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:80:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:100:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in `save'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:120:in `rollback_active_record_state!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in `save'
app/controllers/user_controller.rb:22:in `create'
vendor/plugins/streamlined/lib/streamlined/controller/callbacks.rb:
16:in `execute'
vendor/plugins/streamlined/lib/streamlined/controller/callbacks.rb:
20:in `execute_before_create_and_yield'
app/controllers/user_controller.rb:22:in `create'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in `perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:697:in `call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:689:in `perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
rescue.rb:199:in `perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:678:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
query_cache.rb:8:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:677:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in `process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:685:in `process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session_management.rb:123:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:388:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:171:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:126:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:
112:in `handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
`service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in
`dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:66
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:342:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
script/server:3

***** end trace*******

If I try using
render :file=>"user_notifier/signup_notification"
I get the following error
can't dup NilClass

********* trace log ***********
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
template_error.rb:11:in `dup'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
template_error.rb:11:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
base.rb:322:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
base.rb:322:in `render_file'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
base.rb:348:in `render_without_streamlined'
vendor/plugins/streamlined/lib/streamlined/view/render_methods.rb:
24:in `render'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:502:in `render'
app/models/user_notifier.rb:7:in `signup_notification'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:410:in `__send__'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:410:in `create!'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:403:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:352:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:352:in `method_missing'
app/models/user_observer.rb:5:in `after_create'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
observer.rb:157:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
observer.rb:157:in `update'
c:/ruby/lib/ruby/1.8/observer.rb:185:in `notify_observers'
c:/ruby/lib/ruby/1.8/observer.rb:184:in `each'
c:/ruby/lib/ruby/1.8/observer.rb:184:in `notify_observers'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:338:in `notify'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:302:in `callback'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:227:in `create_without_timestamps'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
timestamp.rb:29:in `create'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:2238:in `create_or_update_without_callbacks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:213:in `create_or_update'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1972:in `save_without_validation'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
validations.rb:934:in `save_without_transactions'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in `save'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/database_statements.rb:66:in
`transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:80:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:100:in `transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in `save'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:120:in `rollback_active_record_state!'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in `save'
app/controllers/user_controller.rb:22:in `create'
vendor/plugins/streamlined/lib/streamlined/controller/callbacks.rb:
16:in `execute'
vendor/plugins/streamlined/lib/streamlined/controller/callbacks.rb:
20:in `execute_before_create_and_yield'
app/controllers/user_controller.rb:22:in `create'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1158:in `perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:697:in `call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:689:in `perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
rescue.rb:199:in `perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:678:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
query_cache.rb:8:in `cache'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
caching.rb:677:in `perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in `process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:685:in `process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session_management.rb:123:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:388:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:171:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:126:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:
112:in `handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
`service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in
`dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:66
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:342:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
script/server:3

********end trace***************

I'm not even sure where to look to solve this one. If any further
info is needed (code etc) please let me know. I didn't want to make
the post too massive.

Your help is much appreciated.

~Ben

render in ActionMailer isn't quite like in a controller, you have to pass in a hash of options. It's also private so you shouldn't be calling really.
If you want to change the template rendered stick

template 'some_other_template'

in your mailer method. if you need to change the directory in which it looks then I believe you need to use mailer_name ie

class SomeMailer < ActionMailer::Base
   mailer_name 'foo_mailer'
   def something
     template 'bar'
   end
end
will render foo_mailer/bar

Fred

Thanks for the feedback Fred,

Just to clarify, I am not trying to render a template in a different
folder (everything is in the "as expected" folders). When I don't
have a render specified, I get the "need to specify the mailer_name"
error.
So In Summary:
views/user_notifier/signup_notification.erb is the render file
models/user_notifier.rb is the ActionMailer class (Class UserNotifier)

In regards to your suggestions the code is now as follows (for the
mailer class):

class UserNotifier < ActionMailer::Base
  mailer_name "user_notifier"
  def signup_notification(user)
    setup_email(user)
    template "signup_notification"
  end
  <snip>
end

Any Thoughts?
Thanks
~Ben

Gah! I forgot to paste the error message.

It is:
wrong number of arguments (1 for 0)

app/models/user_notifier.rb:5:in `mailer_name'
app/models/user_notifier.rb:5
app/models/user_observer.rb:5:in `after_create'
app/controllers/user_controller.rb:22:in `create'
app/controllers/user_controller.rb:22:in `create'

~Ben

Hi All,

I tried setting the mailer_name using:
mailer_name="user_notifier"

I now am back to the start - getting the error
"Due to changes in ActionMailer, you need to provide the mailer_name
along with the template name"

Any Ideas?
Thanks
~Ben

I am getting the same error. I tried to change the directory to
another invalid one.. sure enough it raised an error saying the
template could not be found. But I cannot get past the "can't dup
NilClass " error

here's my model code

class BalUserNotify < ActionMailer::Base
  mailer_name='bal_user_notify'
  def change_password(bal_user, password, url=nil)
    setup_email(bal_user)

    # Email header info
    @subject += "Changed password notification"

    # Email body substitutions

    body[:name] = "#{bal_user.firstname} #{bal_user.lastname}"
    body[:login] = bal_user.login
    body[:password] = password
    body[:url] = url || BalUserSystem::CONFIG[:app_url].to_s
    body[:app_name] = BalUserSystem::CONFIG[:app_name].to_s

    render :file => 'bal_user_notify/change_password'
  end
....

  def setup_email(bal_user)
    @recipients = "#{bal_user.email}"
    @from = BalUserSystem::CONFIG[:email_from].to_s
    @subject = "[#{BalUserSystem::CONFIG[:app_name]}] "
    @sent_on = Time.now
    @headers['Content-Type'] = "text/plain;
charset=#{BalUserSystem::CONFIG[:mail_charset]}; format=flowed"
  end
end

has anybody successfully upgraded to rails 2.0 and succeeded with
converting the mailer models/views?

here's the stack errors too

C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
template_error.rb:11:in `dup'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
template_error.rb:11:in `initialize'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
base.rb:322:in `new'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
base.rb:322:in `render_file'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/
base.rb:348:in `render'
C:/ruby/lib/ruby/gems/1.8/gems/actionmailer-2.0.2/lib/action_mailer/
base.rb:502:in `render'
app/models/bal_user_notify.rb:72:in `change_password'

I am getting the same error. I tried to change the directory to
another invalid one.. sure enough it raised an error saying the
template could not be found. But I cannot get past the "can't dup
NilClass " error

In actionmailer render is private. Don't call it (besides, you're
rendering the default so it's completely superfluous)

Fre

when i remove that line i am back to this line

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

when i remove that line i am back to this line

your mailer_name = should be self.mailer_name = 'foo' or mailer_name
'foo' (mailer_name = 'foo' just creates a local variable)

If you are going to call render yourself, you need to give it a body
option (the set of assigns, eg :body => {:name => 'Bob'}, or in your
case :body => body since you have built that.)

Fred

Ok, i have changed the mailer_name = “foo” to self.mailer_name = “bal_user_notify”

and the class/function to
class BalUserNotify < ActionMailer::Base
self.mailer_name=‘bal_user_notify’

def change_password(bal_user, password, url=nil)
setup_email(bal_user)

# Email body substitutions

body[:name] = "#{bal_user.firstname} #{bal_user.lastname}"
body[:login] = bal_user.login
body[:password] = password
body[:url] = url || BalUserSystem::CONFIG[:app_url].to_s
body[:app_name] = BalUserSystem::CONFIG[:app_name].to_s

render :file => 'bal_user_notify/change_password', :body=>body

end
end

I am still getting this error.

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

Ok, i have changed the mailer_name = "foo" to self.mailer_name =
"bal_user_notify"

This isn't making much sense - that error is only raised if there is
no / in the file you are trying to render (which there is). and if
everything is in the default place you shouldn't need to do anything
(i've got several mailers like that - no setting mailer_name, no calls
to render). Might you have a plugin which is messing things up?

Fred

i found out that it was an issue with some localization functions that were a part of the SaltedLoginGenerator.

I removed the localization files from being included and hard-coded the wording in the forms (since i am a 1-language site for now) and that worked.

self.mailer_name=“foo” and then no render lines in the methods

thanks for your help!

Hi Ethan,

I am also running the salted login generator.
Could you take me through what you did to remove the localization files?

Your help would be much appreciated.

~Ben

One thing when i had them set up was in my environment.rb file there were 2 lines
#require ‘localization’
#Localization::load_localized_strings
as you can see i commented them out.

When you do this, your forms and logins will all work still but the issue now will be the localization strings in your forms will now show a variable name instead of the value. What I did was find all of these tags and replace them.

form_helper
input_helper
message_helper
title_helper

basically doing a find of all *_helper in the .rhtml files and replacing with the wording/text I preferred. Since i am an english language only site it wasnt a big deal to me to have them hard coded. Hopefully it wont be too tedious for you.

I hope that works for you. Let me know if you run into problems.

Ethan

Hi,

I got problem in extracting email header like

Ethan Otterlei wrote:

One thing when i had them set up was in my environment.rb file there
were 2
lines
#require 'localization'
#Localization::load_localized_strings
as you can see i commented them out.

When you do this, your forms and logins will all work still but the
issue
now will be the localization strings in your forms will now show a
variable
name instead of the value. What I did was find all of these tags and
replace them.

Thanks for pointing me in this direction Ethan!

Changing all my localizations to hard-coded strings would have been a
lot of work for me so I edited the lib/localization.rb and commented out
these lines:

ActionMailer::Base.module_eval <<-EOL
  private
  def render_message(method_name, body)
    initialize_template_class(body).render_file(method_name +
"_#{CONFIG[:default_language]}")
  end
EOL

and that did the trick for me.

Ryan