Rails - Trace source of deprecation warnings
When I run rspec spec
, Rails shows some warnings for deprecated code. For
example:
DEPRECATION WARNING: ActiveSupport::TimeWithZone.name has been deprecated and
from Rails 7.1 will use the default Ruby implementation.
You can set `config.active_support.remove_deprecated_time_with_zone_name = true`
to enable the new behavior now.
(called from block (3 levels) in <top (required)> at /project_name/spec/libs/file_name.rb:10)
But I don’t know where it came from, cause in my lib, I don’t use ActiveSupport::TimeWithZone.name
I found a way to trace source of deprecation warning after some searching. We can enable the full debugging information by using this code:
ActiveSupport::Deprecation.debug = true
So we can see the call stack of this deprecation warning.