Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to Rails 4.2 issues

I'm trying to upgrade to Rails 4.2 from Rails 4.1.9 and when I attempt to run the console or the server i get the following error. Any thoughts? I thought the html-scanner gem was included with Action::View

gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- action_view/vendor/html-scanner (LoadError)
like image 477
rwilliams Avatar asked Jan 15 '15 19:01

rwilliams


3 Answers

The OP's issue (and mine) was to do with an incompatibility in the prototype-rails gem. This can be fixed by using the "4.2" branch of prototype-rails directly from github. Modify your Gemfile entry as follows:

gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2'

Note that the prototype-rails gem will not be supported from Rails 5 onwards, so now would be as good a time as any to remove this dependency.

like image 195
Mike Pollitt Avatar answered Nov 14 '22 06:11

Mike Pollitt


I believe they removed html-scanner from rails in 4.2 when they switched to rails-html-sanitizer according to the upgrade guide but it seems you can use the rails-deprecated_sanitizer gem to your Gemfile to then re-include the html-scanner library

gem 'rails-deprecated_sanitizer'

Hope this helps!

like image 21
strivedi183 Avatar answered Nov 14 '22 06:11

strivedi183


I've also had this problem on a legacy project. It's a bundler 1.17.3 / ruby 2.4 / rails 4.2.11.3 and it was driving me up the wall.

The following nasty hack worked:

Gemfile:

gem 'rails-deprecated_sanitizer'
gem 'prototype-rails', git: 'https://github.com/rails/prototype-rails.git', branch: '4.2'

but that wasn't enough. I then had to get rails-deprecated_sanitizer to appear where the gems wanted it.

So in my project, I created lib/action_view/vendor/html-scanner.rb:

require 'rails-deprecated_sanitizer'
require 'rails/deprecated_sanitizer/railtie'
require 'rails/deprecated_sanitizer/html-scanner'

(I doubt all three are needed, mind)

This depends on lib being in your load paths of course.

That fixed the problem, and I was finally able to reset the db and launch the server.

like image 1
user208769 Avatar answered Nov 14 '22 06:11

user208769