ActiveSupport:Module 的未定义方法“deprecator”

undefined method `deprecator' for ActiveSupport:Module

提问人:Colibri 提问时间:11/5/2023 最后编辑:Colibri 更新时间:11/5/2023 访问量:61

问:

我有一个 Ruby gem 一直使用这一行,例如使用 和 方法:blank?present?

require "active_support/core_ext/string"

最近有 Rails 的更新。我已更新到版本 7.1.1。此 gem 停止工作并立即返回此错误后:active_support

An error occurred while loading spec_helper.
Failure/Error: require "active_support/core_ext/string"

NoMethodError:
  undefined method `deprecator' for ActiveSupport:Module
# ./lib/gemname.rb:5:in `<top (required)>'
# ./spec/spec_helper.rb:5:in `<top (required)>'

请告诉我,可能有什么问题?

几乎到处都有关于可可足类动物的讨论,但我不明白这与我的情况有什么关系。

通过用以下行替换它来解决此问题:

require "active_support/all"

但这是为什么呢?对于只需要几种特定方法的情况,这似乎不是最佳解决方案。

Ruby-on-Rails RubyGems Active支持

评论

0赞 engineersmnky 11/6/2023
您的问题就在这里(由 rails 7.1 中的添加引起):github.com/rails/rails/blob/7-1-stable/activesupport/lib/...。您将需要这样做,以便该方法存在。include "active_support/deprecator.rb"

答: 暂无答案