2010-11-16 180 views
1

我一直没有找到解决办法如下:Rails控制台 - Hpricot,Nokogiri在Rails控制台中不可用?

安装宝石后,如hpricot或nokogiri,我无法在rails控制台中访问这些。宝石出现在我的宝石列表中,并且似乎与我的其他宝石有相同的路径。

[email protected]:~$ which nokogiri 
/home/user/.rvm/gems/ruby-1.9.2-p0/bin/nokogiri 
[email protected]:~$ which rake 
/home/user/.rvm/gems/ruby-1.9.2-p0/bin/rake 

在控制台,对于 “标准” 的宝石,他们能够要求,例如:

ruby-1.9.2-p0 > require 'open-uri' 
=> ["OpenURI"] 

然而,需要引入nokogiri返回如下:

ruby-1.9.2-p0 > require 'nokogiri' 
LoadError: no such file to load -- nokogiri 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `block in load_dependency' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
    from (irb):10 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/console.rb:44:in `start' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/console.rb:8:in `start' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:23:in `<top (required)>' 
    from script/rails:9:in `require' 
    from script/rails:9:in `<main>' 

无论如何,我真的很感谢帮助我的新问题,一直在这一天的大部分时间里挣扎。 :)

回答

3

您是否将宝石添加到Gemfile中?当控制台启动时,它们将自动加载。

+0

就是这样!那..那真是令人尴尬。哈哈,我真的很感激它。 – Kombo 2010-11-16 21:22:46

+0

我很高兴,它的工作,记得接受解决您的问题的答案,使他们不显示为解决了。 – 2010-11-16 21:45:18