[英]Getting a LoadError when using nokogiri gem in my ruby on rails application
When I put in a require statement to load the nokogiri gem I get a load error: no such file to load -- nokogiri 当我在require语句中加载nokogiri gem时,出现加载错误: 没有要加载的此类文件-nokogiri
requires:
要求:
require 'rubygems'
require 'nokogiri'
gemfile:
的Gemfile:
source 'https://rubygems.org'
source 'http://gems.github.com'
gem 'rails', '3.2.3'
gem 'rubygems'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'json'
# HTML Parser
gem 'nokogiri'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Also I am using ruby v1.8 我也在用ruby v1.8
I was having the same problem as you, but at last I didn't need those "require" to make it work. 我遇到了与您相同的问题,但最后我不需要那些“要求”来使其正常工作。
The problem I was having was because I didn't restarted the Application after installing nokogiri. 我遇到的问题是因为我在安装nokogiri之后没有重新启动应用程序。 Once I restarted the app, nokogiri worked just fine without those 2 "require" lines.
重新启动应用程序后,nokogiri在没有这两个“ require”行的情况下工作正常。 The only "require" I needed at last was the "open-uri" because I was trying to scrap a remote page.
最后,我唯一需要的“要求”是“ open-uri”,因为我正尝试抓取远程页面。
Hope that helps. 希望能有所帮助。
I guess you did put the require 'nokogiri'
inside the config/boot.rb. 我猜您确实在config / boot.rb中放了
require 'nokogiri'
。 That's not the place, to do that. 那不是那个地方。
Put it just at beginning of the file where you want to use it, or in an initializer or so. 将其放在要使用它的文件的开头,或放在初始化程序中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.