From a454dcf012e13f24c6c74098f9fd4efd72e8aadc Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 8 Dec 2006 22:19:00 +0000 Subject: Unrescued ActiveRecord::RecordNotFound responds with 404 instead of 500. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5706 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/rescue.rb | 3 ++- actionpack/test/controller/rescue_test.rb | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index d9ba19526b..8ffbe8f88a 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Unrescued ActiveRecord::RecordNotFound responds with 404 instead of 500. [Jeremy Kemper] + * Improved auto_link to match more valid urls correctly [Tobias Luetke] * Add singleton resources. [Rick Olson] diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 08ee699f7f..01969e867c 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -11,7 +11,8 @@ module ActionController #:nodoc: DEFAULT_RESCUE_RESPONSE = :internal_server_error DEFAULT_RESCUE_RESPONSES = { 'ActionController::RoutingError' => :not_found, - 'ActionController::UnknownAction' => :not_found + 'ActionController::UnknownAction' => :not_found, + 'ActiveRecord::RecordNotFound' => :not_found } DEFAULT_RESCUE_TEMPLATE = 'diagnostics' diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index c49575cad3..c18de75c05 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -143,6 +143,7 @@ class RescueTest < Test::Unit::TestCase assert_equal :not_found, responses[ActionController::RoutingError.name] assert_equal :not_found, responses[ActionController::UnknownAction.name] + assert_equal :not_found, responses['ActiveRecord::RecordNotFound'] end def test_rescue_templates -- cgit v1.2.3