开发者

Rails Console - Hpricot, Nokogiri Unavailable in Rails Console?

I haven't been able to find a solution the following:

After installing gems, such as hpricot or nokogiri, I'm unable to access these within the rails console. The gems show up within my gem list, and also seem to have the same path as my other gems.

user@user-laptop:~$ which nokogiri
/home/user/.rvm/gems/ruby-1.9.2-p0/bin/nokogiri
user@user-laptop:~$ which rake
/home/user/.rvm/gems/ruby-1.9.2-p0/bin/rake

Within the console, for the "standard" gems, they're able to be required, for example:

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

However, requiring nokogiri returns the following:

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>'

Anyway, I truly appreciate the help to my newb question, been struggling with this most of the day. :)


Have you added the gems to Gemfile? They will be auto-loaded then when console starts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜