No rhtml, rxml, rjs or delegate template found

After upgrading to Ruby on Rails 1.1.6 (with a one-day 1.1.5 intermezzo), we’ve found a strange error in our Recykl.com application. Most of the application behaved normally, but email sending got broken with the following error:


ActionView::ActionViewError (No rhtml, rxml, rjs or delegate template found for notification_email):
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:389:in `find_template_extension_for’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:323:in `pick_template_extension’
/vendor/plugins/globalize/lib/globalize/rails/action_view.rb:29:in `locate_globalize_path’
/vendor/plugins/globalize/lib/globalize/rails/action_view.rb:10:in `render_file’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:274:in `render’
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:427:in `render’
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:422:in `render_message’
/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb:110:in `render_localized_normal_template’
/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb:98:in `render_localized_normal_template’
/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb:47:in `create!’
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:331:in `initialize’
/usr/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb:290:in `method_missing’
/app/controllers/home_controller.rb:123:in `notify’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue’
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:150:in `process_request’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:54:in `process!’
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:600:in `each_cgi’
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in `each_cgi’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:53:in `process!’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/fcgi_handler.rb:23:in `process!’
/recykl/public/dispatch.fcgi:36

The error only occurred in our production environment on Linux – I could not reproduce it anywhere else. 🙁

Nothing in the application or server configuration had changed, so the problem had to be in the upgraded Rails – I compared the installed gems and among other things found the following difference in the actionmailer package:


— /ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.3/lib/action_mailer/base.rb 2006-07-01 10:53:54.500000000 +0200
+++ /ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.5/lib/action_mailer/base.rb 2006-08-11 08:46:36.687500000 +0200
@@ -5,20 +5,92 @@
@@ -127,7 +191,7 @@

private_class_method :new #:nodoc:

– cattr_accessor :template_root
+ class_inheritable_accessor :template_root
cattr_accessor :logger

@@server_settings = {

This change in the inheritance scoping is not very well documented, but I’ve decided to anyway re-define the standard template root explicitly for our NotificationMailer class:


— /recykl/app/models/notification_mailer.rb (revision 122)
+++ /recykl/app/models/notification_mailer.rb (revision 123)
@@ -11,15 +11,18 @@
class NotificationMailer < ActionMailer::Base + # for some reason, after upgrade to Rails 1.1.6 this is needed in production for correct operation, although earlier it was not + NotificationMailer.template_root = File.dirname(__FILE__) + '/../views' + def confirm(notification) @subject = 'Notification regarding'.t

And, tada! It works!

6 comments

  1. I had the same problem today (also with Rails 1.1.6). I can confirm that the solution suggested in this article works.
    Did you report this problem to the Rails developers?

  2. Your my new best friend!!… at least until the next time I kind find out why something is broken.

  3. You rock buddy. I started with rails 1.1.6 and I had no clue why it is failing! Thanks a ton for making my day 🙂

  4. I have this problem too, thanks. Might even be a ruby bug with inconsistent scoping behaviour between linux and os x (where it seems to work fine)… or just some kind of platform-specific bug deep in rails internals… :-/

    You should file a Rails ticket anyway!

Comments are closed.