在 Ruby 1.9.2 中使用 ActiveSupport 失败
我需要在 Ruby 脚本中使用 ActiveSupport,如下所示:
require 'rubygems'
require 'active_support/core_ext/hash'
使用 some_hash.with_in Different_access。
在 Ruby 1.8 中工作正常,但 Ruby 1.9 抛出以下异常:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- active_support/core_ext/hash (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from backup.rb:3:in `<main>'
在 Ruby 1.9.2 中执行此操作的正确方法是什么?
I am requiring ActiveSupport in a Ruby script like so:
require 'rubygems'
require 'active_support/core_ext/hash'
to use some_hash.with_indifferent_access.
In Ruby 1.8 that worked fine but Ruby 1.9 throws the following exception:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- active_support/core_ext/hash (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from backup.rb:3:in `<main>'
What is the correct way to do this in Ruby 1.9.2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 ruby 1.9.2 和 activesupport 2.3.5 中也遇到了同样的问题。运行
gem update activesupport
,更新到3.2.9,问题就消失了。Ran into this same issue with ruby 1.9.2 and activesupport 2.3.5. Ran
gem update activesupport
, updated to 3.2.9, and the issue went away.首先,Ruby 1.9 已经包含 rubygems,因此您不需要包含它。
其次,这对我来说在 Ruby 1.9.1 和 Ruby 1.9.2 with ActiveSupport 3.0.3 下工作得很好。您确定在您测试的同一 Ruby 环境下正确安装了
activesupport
gem 吗? (也许ruby --version
和gem list
可能会显示一些错误。)First, Ruby 1.9 includes rubygems already, so you don't need to include that.
Secondly, this works fine for me under Ruby 1.9.1 and Ruby 1.9.2 with ActiveSupport 3.0.3. Are you sure that you have the
activesupport
gem installed properly under the same Ruby environment that you are testing with? (Perhapsruby --version
andgem list
might show something awry.)