在 Ruby 1.9.2 中使用 ActiveSupport 失败

发布于 2024-10-01 23:18:58 字数 516 浏览 0 评论 0原文

我需要在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情深如许 2024-10-08 23:18:58

ruby 1.9.2activesupport 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.

愿与i 2024-10-08 23:18:58

首先,Ruby 1.9 已经包含 ruby​​gems,因此您不需要包含它。

其次,这对我来说在 Ruby 1.9.1 和 Ruby 1.9.2 with ActiveSupport 3.0.3 下工作得很好。您确定在您测试的同一 Ruby 环境下正确安装了 activesupport gem 吗? (也许ruby --versiongem 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? (Perhaps ruby --version and gem list might show something awry.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文