Fix render_views for anonymous controllers on 1.8.7. #525
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
controller.
We can fix this by declaring an anonymous controller's name on
creation and then evaluating the body of the controller with
class_eval
.This fixes issue #450.