本文介绍了Rails 3 中的 require rack/openid 问题[本机需要正常工作]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装插件 open_id_authentication 并出现此错误:

I install plugin open_id_authentication and have this error:

/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to load -- rack/openid (LoadError)

当我尝试启动 rails server实际上,我的系统中安装了 rack-openid,我可以从 irb 加载它:

when I try to start rails serverActually, rack-openid installed in my system and i can load it from irb:

irb(main):001:0> require 'rack/openid'
=> true

我尝试像使用 ruby​​-openid 一样向 Gemfile 添加 hack,但没有帮助:

I tried to add hack to Gemfile as I did with ruby-openid, but it did't help:

gem "ruby-openid", :require => "openid"
gem "rack-openid", :require => "rack/openid"

我也试过

gem "ruby-openid", :require => "rack/openid"

但是:

/usr/lib/ruby/gems/1.9.1/gems/bundler-0.9.7/lib/bundler/runtime.rb:38:in `require': no such file to load -- rack/openid (LoadError)

在 rails 2.3.5 应用程序中没有这个问题,我不明白为什么它会在 Rails 3 中发生.

In rails 2.3.5 app there isn't this problem and I can't understand why it happens in Rails 3.

推荐答案

问题是插件的init.rb最上面这段代码

The problem is this code at the top of the plugin's init.rb

if Rails.version < '3'
  config.gem 'rack-openid', :lib => 'rack/openid', :version => '>=0.2.1'
end

Bundler 似乎没有满足 gem 要求,因此您缺少 rack-openid gem.

Bundler doesn't seem to pick up on the gem requirement so you are missing the rack-openid gem.

解决方案是将以下内容添加到您的 Gemfile 中以代替 ruby-openid.(rack-openid 依赖于 ruby-openid 但 gems 知道这一点,并会根据需要安装它)

The solution is to add the following to your Gemfile in place of ruby-openid. (rack-openid depends on ruby-openid but gems is aware of this and will install it as needed)

gem 'rack-openid', '>=0.2.1', :require => 'rack/openid'

不要忘记在更新 Gemfile 后运行 bundle install.

Don't forget to run bundle install after updating your Gemfile.

这篇关于Rails 3 中的 require rack/openid 问题[本机需要正常工作]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 22:06