aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorSteven Soroka <ssoroka78@gmail.com>2011-07-27 18:37:06 -0400
committerSteven Soroka <ssoroka78@gmail.com>2012-05-06 00:27:45 -0500
commit3532200576bed84bedf3554336dfc92ce9ce1cab (patch)
treeeaa5e12876640ce05056abcefc63c5b1dddd536f /actionpack/lib
parentbad119cae5ff6f3d27d82b9bdc9fc3cf4f67d271 (diff)
downloadrails-3532200576bed84bedf3554336dfc92ce9ce1cab.tar.gz
rails-3532200576bed84bedf3554336dfc92ce9ce1cab.tar.bz2
rails-3532200576bed84bedf3554336dfc92ce9ce1cab.zip
Raise a rescuable exception when Rails doesn't know what to do with the format, rather than responding with a head :not_acceptable (406)
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/exceptions.rb3
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb3
-rw-r--r--actionpack/lib/action_dispatch/middleware/exception_wrapper.rb1
3 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/exceptions.rb b/actionpack/lib/action_controller/metal/exceptions.rb
index 9a9db0fe5f..90648c37ad 100644
--- a/actionpack/lib/action_controller/metal/exceptions.rb
+++ b/actionpack/lib/action_controller/metal/exceptions.rb
@@ -38,4 +38,7 @@ module ActionController
class UnknownHttpMethod < ActionControllerError #:nodoc:
end
+
+ class UnknownFormat < ActionControllerError #:nodoc:
+ end
end
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index f467b74256..2c96145820 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -375,8 +375,7 @@ module ActionController #:nodoc:
lookup_context.rendered_format = lookup_context.formats.first
collector
else
- head :not_acceptable
- nil
+ raise ActionController::UnknownFormat.new
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
index c0532c80c4..982f6641bf 100644
--- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
+++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
@@ -10,6 +10,7 @@ module ActionDispatch
'AbstractController::ActionNotFound' => :not_found,
'ActionController::MethodNotAllowed' => :method_not_allowed,
'ActionController::NotImplemented' => :not_implemented,
+ 'ActionController::UnknownFormat' => :not_acceptable,
'ActionController::InvalidAuthenticityToken' => :unprocessable_entity
)