aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2012-09-16 21:48:24 +0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-09-17 13:39:01 -0300
commitdd76b3bbc8c4b161e6d4f77012c90960f68d1ac3 (patch)
tree9c011f81fd0c4ae9a33410686cfdc5901d0da9e4 /actionpack/lib
parentee439895759b38431ad025f3c234831f30dadcdb (diff)
downloadrails-dd76b3bbc8c4b161e6d4f77012c90960f68d1ac3.tar.gz
rails-dd76b3bbc8c4b161e6d4f77012c90960f68d1ac3.tar.bz2
rails-dd76b3bbc8c4b161e6d4f77012c90960f68d1ac3.zip
log 404 status when ActiveRecord::RecordNotFound was raised (#7646)
Conflicts: actionpack/CHANGELOG.md actionpack/lib/action_controller/log_subscriber.rb
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/log_subscriber.rb3
-rw-r--r--actionpack/lib/action_dispatch/middleware/exception_wrapper.rb8
2 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/log_subscriber.rb b/actionpack/lib/action_controller/log_subscriber.rb
index 4c76f4c43b..194f26aefc 100644
--- a/actionpack/lib/action_controller/log_subscriber.rb
+++ b/actionpack/lib/action_controller/log_subscriber.rb
@@ -20,7 +20,8 @@ module ActionController
status = payload[:status]
if status.nil? && payload[:exception].present?
- status = Rack::Utils.status_code(ActionDispatch::ExceptionWrapper.new({}, payload[:exception]).status_code)
+ exception_class_name = payload[:exception].first
+ status = ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name)
end
message = "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in %.0fms" % event.duration
message << " (#{additions.join(" | ")})" unless additions.blank?
diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
index c0532c80c4..0f49dc65bf 100644
--- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
+++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
@@ -34,7 +34,7 @@ module ActionDispatch
end
def status_code
- Rack::Utils.status_code(@@rescue_responses[@exception.class.name])
+ self.class.status_code_for_exception(@exception.class.name)
end
def application_trace
@@ -49,6 +49,10 @@ module ActionDispatch
clean_backtrace(:all)
end
+ def self.status_code_for_exception(class_name)
+ Rack::Utils.status_code(@@rescue_responses[class_name])
+ end
+
private
def original_exception(exception)
@@ -75,4 +79,4 @@ module ActionDispatch
@backtrace_cleaner ||= @env['action_dispatch.backtrace_cleaner']
end
end
-end \ No newline at end of file
+end