can't load require_dependency

半城伤御伤魂 提交于 2019-12-13 16:17:59

问题


I'm trying to use require_dependency from ActiveSupport library in pry:

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

What could be the problem?


回答1:


ActiveSupport used to be pretty evil by loading a ton of stuff on require. The "kitchen sink" approach opened a lot of core classes up and changed their behavior (like JSON). This caused incompatibilities/problems with other gems and code that expected core ruby functions to behave like their vanilla selves.

So now requiring just active_support does not load anything.

see http://edgeguides.rubyonrails.org/active_support_core_extensions.html

in your case you probably will need require 'active_support/core_ext'



来源:https://stackoverflow.com/questions/11021955/cant-load-require-dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!