From a5c3549e3204cd3d0c558fb98e7f5390f367a806 Mon Sep 17 00:00:00 2001 From: Jakub Suder Date: Fri, 20 Aug 2010 20:05:38 +0200 Subject: [PATCH] better callstack reporting in deprecation messages now the reported line is the first line in the stack that's outside Rails, which is the one that actually caused the problem in the first place --- .../lib/active_support/deprecation/reporting.rb | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb index 49d58cd..4141f13 100644 --- a/activesupport/lib/active_support/deprecation/reporting.rb +++ b/activesupport/lib/active_support/deprecation/reporting.rb @@ -46,10 +46,14 @@ module ActiveSupport end def extract_callstack(callstack) - if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) - md.captures - else - callstack.first + rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/" + first_external = callstack.find { |line| !line.start_with?(rails_gem_root) } + if first_external + if md = first_external.match(/^(.+?):(\d+)(?::in `(.*?)')?/) + md.captures + else + first_external + end end end end -- 1.6.4.4