Skip to content

Instantly share code, notes, and snippets.

@yakjuly
Forked from hlxwell/missing_template_fix.rb
Created December 26, 2011 10:14
Show Gist options
  • Save yakjuly/1520852 to your computer and use it in GitHub Desktop.
Save yakjuly/1520852 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