Created
December 24, 2011 09:43
-
-
Save hlxwell/1517007 to your computer and use it in GitHub Desktop.
Patch to fix MissingTemplate issue in Rails 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionController | |
module ImplicitRender | |
def default_render | |
# lookup template exist? go to render it | |
render and return if template_exists?(action_name.to_s, _prefix) | |
has_template = begin | |
old_formats, @lookup_context.formats = @lookup_context.formats, Mime::SET.symbols | |
template_exists?(action_name.to_s, _prefix) | |
ensure | |
@lookup_context.formats = old_formats | |
end | |
# if lookup template not exist then go to check if any template existed, | |
# if so show 406, if not, go render, it will give MissingTemplate error. | |
has_template ? head(:not_acceptable) : render | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment