From 7c79bd8ce72b910e42c6a859b8c54de93f339e74 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..6a7b11c 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__) + "/" + offending_line = callstack.find { |line| !line.start_with?(rails_gem_root) } || callstack.first + if offending_line + if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/) + md.captures + else + offending_line + end end end end -- 1.6.4.4