# Nil while creating message in ActionMailer

**URL:** <https://www.ruby-forum.com/t/nil-while-creating-message-in-actionmailer/89253>\
**Category:** Rails\
**Created:** [March 19, 2007, 12:34am UTC](https://www.ruby-forum.com/t/nil-while-creating-message-in-actionmailer/89253 "2007-03-19T00:34:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b2d939/32.png) [@Nick\_Allen](https://www.ruby-forum.com/u/Nick_Allen)\
**Post date:** [March 19, 2007, 12:34am UTC](https://www.ruby-forum.com/t/nil-while-creating-message-in-actionmailer/89253/1 "2007-03-19T00:34:15Z")

</div>

I have created an ActionMailer and am able to use it successfully in  
development. As soon as I move it to the production environment, I am  
getting an exception. It seems like it must be some kind of  
configuration issue. Does any have an idea based on the stack trace?

> > RegistrationMailer.create\_confirm(reg)  
> > TypeError: can’t convert nil into String  
> > from  
> > ./script/…/config/…/config/…/vendor/plugins/engines/lib/engines/rails\_extensions/templates.rb:128:in  
> > `dirname' from ./script/../config/../config/../vendor/plugins/engines/lib/engines/rails_extensions/templates.rb:128:in`render’  
> > from  
> > /usr/lib/ruby/gems/1.8/gems/actionmailer-1.3.2/lib/action\_mailer/base.rb:476:in  
> > `render_message' from /usr/lib/ruby/gems/1.8/gems/actionmailer-1.3.2/lib/action_mailer/base.rb:424:in`create!’  
> > from  
> > /usr/lib/ruby/gems/1.8/gems/actionmailer-1.3.2/lib/action\_mailer/base.rb:385:in  
> > `initialize' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/core_ext/module/attribute_accessors.rb:26:in`new’  
> > from  
> > /usr/lib/ruby/gems/1.8/gems/actionmailer-1.3.2/lib/action\_mailer/base.rb:332:in  
> > `method\_missing’  
> > from (irb):3

---

<div class="post-metadata">

**Author:** ![Nick\_Allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b2d939/32.png) [@Nick\_Allen](https://www.ruby-forum.com/u/Nick_Allen)\
**Post date:** [March 20, 2007, 1:43am UTC](https://www.ruby-forum.com/t/nil-while-creating-message-in-actionmailer/89253/2 "2007-03-20T01:43:26Z")

</div>

In my production environment the template path was not being set  
correctly. It was not looking in my apps/views directory for the mail  
template. I had to manually set the template root…

ActionMailer::Base.template\_root = “#{RAILS\_ROOT}/app/views”

Why did this work in development, but not in production?

---

<div class="post-metadata">

**Author:** ![Nick\_Allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b2d939/32.png) [@Nick\_Allen](https://www.ruby-forum.com/u/Nick_Allen)\
**Post date:** [March 21, 2007, 12:40am UTC](https://www.ruby-forum.com/t/nil-while-creating-message-in-actionmailer/89253/3 "2007-03-21T00:40:49Z")

</div>

> ActionMailer::Base.template\_root = “#{RAILS\_ROOT}/app/views”

This still doesnt seem to be resolved if I manually set the  
template\_root. Where does the template\_root normally get set from? Why  
is the setting for template\_root in development different than  
production?
