ruby-on-railsruby

How to resolve uninitialized constant Nokogiri::HTML4 using Ruby in Rails


I start to learn ruby on rails

I am using ruby version 2.2.1 and rails version 4.2.7.1 to create my application , when i tried this

rails generate scaffold post title:string body:text

i get error

/home/work/.rvm/gems/ruby-2.2.1/gems/loofah-2.21.1/lib/loofah/html4/document.rb:10:in `<module:HTML4>': uninitialized constant Nokogiri::HTML4 (NameError)

Solution

  • There seems to be a mismatch between gem versions. You should post your Gemfile and Gemfile.lock and try updating what you can without breakage. "Before v1.12.0, Nokogiri::HTML4 did not exist," https://nokogiri.org/rdoc/Nokogiri/HTML4.html, so see what Nokogiri version you have and try to update it.