lib/action_controller/responder.rb in responders-2.1.1 vs lib/action_controller/responder.rb in responders-2.1.2
- old
+ new
@@ -180,14 +180,16 @@
# All other formats follow the procedure below. First we try to render a
# template, if the template is not available, we verify if the resource
# responds to :to_format and display it.
#
def to_format
- if get? || !has_errors? || response_overridden?
+ if !get? && has_errors? && !response_overridden?
+ display_errors
+ elsif has_view_rendering? || response_overridden?
default_render
else
- display_errors
+ api_behavior
end
rescue ActionView::MissingTemplate
api_behavior
end
@@ -269,9 +271,13 @@
end
# Check whether the necessary Renderer is available
def has_renderer?
Renderers::RENDERERS.include?(format)
+ end
+
+ def has_view_rendering?
+ controller.class.include? ActionView::Rendering
end
# By default, render the <code>:edit</code> action for HTML requests with errors, unless
# the verb was POST.
#