简体   繁体   中英

private method `include' called for ActionDispatch::Assertions:Module (NoMethodError)

I tried to run an old rails app and I got this error when I access the main page: I'm using ruby 2.0.0p648.

private method `include' called for ActionDispatch::Assertions:Module (NoMethodError)
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/turbolinks-5.2.1/lib/turbolinks.rb:25:in `block (2 levels) in <class:Engine>'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/activesupport-4.2.11.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/activesupport-4.2.11.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/activesupport-4.2.11.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/activesupport-4.2.11.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/activesupport-4.2.11.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/actionpack-4.2.11.1/lib/action_controller/base.rb:266:in `<class:Base>'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/actionpack-4.2.11.1/lib/action_controller/base.rb:164:in `<module:ActionController>'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/actionpack-4.2.11.1/lib/action_controller/base.rb:5:in `<top (required)>'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/actionpack-4.2.11.1/lib/action_dispatch/middleware/static.rb:69:in `ext'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/actionpack-4.2.11.1/lib/action_dispatch/middleware/static.rb:27:in `match?'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/actionpack-4.2.11.1/lib/action_dispatch/middleware/static.rb:114:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/rack-1.6.13/lib/rack/sendfile.rb:113:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/railties-4.2.11.1/lib/rails/engine.rb:518:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/railties-4.2.11.1/lib/rails/application.rb:165:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/rack-1.6.13/lib/rack/content_length.rb:15:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/puma-3.11.4/lib/puma/configuration.rb:225:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/puma-3.11.4/lib/puma/server.rb:632:in `handle_request'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/puma-3.11.4/lib/puma/server.rb:446:in `process_client'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/puma-3.11.4/lib/puma/server.rb:306:in `block in run'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `call'
/home/armano/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

This is my Gemfile:

source 'https://rubygems.org'

gem 'rails', '~> 4.0'
gem 'sqlite3', '~> 4.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'

gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

gem 'puma', '~> 3.11'

Anyone here encountered this error? How did you fix it? Thanks

For most gems you have specified a version in the Gemfile, but not for turbolinks. If you also don't have a Gemfile.lock, this makes that bundle installs the last version available in RubyGems, which is at the moment 5.2.1 (which is the one you are using according to the error message). I assume that the current version of turbolinks doesn't work with Ruby 2.0, because it is really old and it is not even maintained anymore. So, I recomend you to use the same turboliinks version as the last time you run the up. In case you don't know which one I would try with an older version. Check versions list: https://rubygems.org/gems/turbolinks/versions

Alternatively you could update Ruby to a newer version. But I would do this progressively, because this may break other things. You may want to update Ruby anyway, as I have mentioned already it is an old version which doesn't receive security updates.

Ruby on Rails version 4.0 was up-to-date between mid 2013 and end of 2014 . During that time turbolinks' versions were in the 1.3-2.5 range .

I would downgrade turbolinks to its lastest 1.x version

# in the Gemfile
gem 'turbolinks', '~> 1.3'

run

bundle install

and try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM