This patch fixes two issues in render.rb.
After checking out the latest Merb trunk on 8/15/07 and testing the Invoice Tracker app found at http://svn.depixelate.com/applications/invoice_tracker/, I found an issue in which the controller's call to render was bombing but only on the first request.
can't convert nil into String - (TypeError)
/usr/local/lib/ruby/gems/1.8/gems/merb-0.4.0/lib/merb/template/erubis.rb:36:in `read'
/usr/local/lib/ruby/gems/1.8/gems/merb-0.4.0/lib/merb/template/erubis.rb:36:in `new_eruby_obj'
/usr/local/lib/ruby/gems/1.8/gems/merb-0.4.0/lib/merb/template/erubis.rb:25:in `transform'
/usr/local/lib/ruby/gems/1.8/gems/merb-0.4.0/lib/merb/mixins/render.rb:151:in `render'
/usr/local/httpd/invoice_tracker/app/controllers/clients.rb:7:in `new'
Per the Rdoc, calling just plain "render" should look for a file matching "views/controllername/actionname.*"
However, after tracing the code, the render function was attempting (via find_template) to look for:
/usr/local/httpd/invoice_tracker/app/views/clients/index.{}
...because at this point, the template engine has not yet been registered and so @@template_extensions is empty.
The first part of the patch changes the above to
/usr/local/httpd/invoice_tracker/app/views/clients/index.{*}
After resolving the above, a new error popped up:
undefined method `transform' for nil:NilClass - (NoMethodError)
/usr/local/lib/ruby/gems/1.8/gems/merb-0.4.0/lib/merb/mixins/render.rb:153:in `render'
Similar to the above issue, since the templating engine was not yet registered, the engine_for function was returning a null object. With this patch, the engine_for function defaults to Erubis to be consistent with the exception trap.
In case this is helpful, I'm running ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0] on MacOSX 10.4.10.