无法在ruby 2.1.5中加载`active_support / core_ext`

时间:2014-12-28 05:58:45

标签: ruby

当我require 'active_support/core_ext'时,会收到错误:

NameError: uninitialized constant ActiveSupport::Autoload from /opt/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/number_helper.rb:3:in `<module:NumberHelper>'

当然我安装了activesupport gem。

# gem list --local | grep activesupport
activesupport (4.2.0)

我应该安装其他一些宝石来使用active_support/core_ext吗?

我在Ubuntu14.04中使用ruby 2.1.5p273

1 个答案:

答案 0 :(得分:2)

假设您正在使用bundler,请尝试使用此诊断代码查看哪些有效:

require 'rubygems'        # You may be able to omit this line
require 'bundler/setup'   # You may be able to omit this line
require 'active_support'
require 'active_support/core_ext' 

较新的Ruby版本可能会跳过rubygemssetupcore_ext,只需使用它:

require 'active_support'