Skip to content

Instantly share code, notes, and snippets.

@hlxwell
Created December 24, 2011 09:43
Show Gist options
  • Save hlxwell/1517007 to your computer and use it in GitHub Desktop.
Save hlxwell/1517007 to your computer and use it in GitHub Desktop.
Patch to fix MissingTemplate issue in Rails 3
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