Skip to content

Fix render_views for anonymous controllers on 1.8.7. #525

wants to merge 1 commit into from
Commits on Apr 2, 2012
  1. @mudge

    Fix render_views for anonymous controllers on 1.8.7.

    James Hunt & Paul Mucur committed with mudge Apr 1, 2012
    Rails uses a controller's class name to determine the layout to use when
    rendering views but it does so with an inherited hook. This means that
    setting the name of a class *after* it inherits is too late. This is not
    an issue in Ruby 1.9.2 as the name of an anonymous module is set to nil
    but in 1.8.7 it is set to the empty string (which, of course, is a
    truthy value). This causes Rails to throw a "can't convert nil into
    String" error when attempting to render views from an anonymous
    We can fix this by declaring an anonymous controller's name *on
    creation* and then evaluating the body of the controller with
Something went wrong with that request. Please try again.