Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby can';不需要加载依赖项_Ruby_Activesupport - Fatal编程技术网

Ruby can';不需要加载依赖项

Ruby can';不需要加载依赖项,ruby,activesupport,Ruby,Activesupport,我正在尝试使用pry中的ActiveSupport库中的require\u dependency: require 'active_support' #=> true require_dependency 'test' #=> NoMethodError: undefined method #=> `require_dependency' for main:Object 有什么问题吗?ActiveSupport过去非常

我正在尝试使用pry中的
ActiveSupport
库中的
require\u dependency

require 'active_support'  #=> true
require_dependency 'test' #=> NoMethodError: undefined method  
                          #=> `require_dependency' for main:Object

有什么问题吗?

ActiveSupport过去非常糟糕,在require上加载了大量的东西。“厨房水槽”方法打开了许多核心类并改变了它们的行为(比如JSON)。这导致了与其他gem和代码的不兼容/问题,这些gem和代码期望核心ruby函数的行为像它们的普通函数一样

因此,现在只需要主动_支持就不会加载任何内容


在您的情况下,您可能需要
require'active\u-support/core\u-ext'

ActiveSupport过去在require上加载了大量的东西,这是一种非常邪恶的行为。“厨房水槽”方法打开了许多核心类并改变了它们的行为(比如JSON)。这导致了与其他gem和代码的不兼容/问题,这些gem和代码期望核心ruby函数的行为像它们的普通函数一样

因此,现在只需要主动_支持就不会加载任何内容


在您的情况下,您可能需要
require'active\u support/core\u ext'

这一行:require'active\u support/dependencies'是的,谢谢这一行,它将帮助未来看到这一点的人。这一行:require'active\u support/dependencies'是的,谢谢这一行,它将帮助未来看到这一点的人。