简体   繁体   English

为 ActionDispatch::Assertions:Module (NoMethodError) 调用私有方法“include”

[英]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.我尝试运行旧的 Rails 应用程序,但在访问主页时出现此错误:我正在使用 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:这是我的 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.对于大多数 gem,您已经在 Gemfile 中指定了一个版本,但没有为 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).如果您也没有 Gemfile.lock,这将使该捆绑包安装 RubyGems 中可用的最后一个版本,目前是 5.2.1(根据错误消息,这是您正在使用的版本)。 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.我认为当前版本的 turbolinks 不适用于 Ruby 2.0,因为它真的很旧,甚至不再维护。 So, I recomend you to use the same turboliinks version as the last time you run the up.所以,我建议您使用与上次运行时相同的 turboliinks 版本。 In case you don't know which one I would try with an older version.如果你不知道我会用旧版本尝试哪一个。 Check versions list: https://rubygems.org/gems/turbolinks/versions检查版本列表: https://rubygems.org/gems/turbolinks/versions

Alternatively you could update Ruby to a newer version.或者,您可以将 Ruby 更新到较新的版本。 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,因为我已经提到它是不接收安全更新的旧版本。

Ruby on Rails version 4.0 was up-to-date between mid 2013 and end of 2014 . Ruby on Rails 版本 4.0 在2013 年中至 2014 年底之间是最新的。 During that time turbolinks' versions were in the 1.3-2.5 range .在那段时间里,turbolinks 的版本在 1.3-2.5 范围内

I would downgrade turbolinks to its lastest 1.x version我会将 turbolinks 降级到其最新的 1.x 版本

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

run

bundle install

and try again.然后再试一次。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NoMethodError-#的未定义方法`email&#39; - NoMethodError - undefined method `email' for #<ActionDispatch:: NoMethodError:调用#的私有方法“ permit” - NoMethodError: private method `permit' called for #<Devise::ParameterSanitizer NoMethodError:私有方法`warn&#39;调用nil:NilClass - NoMethodError: private method `warn' called for nil:NilClass Prawn-NoMethodError:调用对象的私有方法“ p” - Prawn - NoMethodError: private method `p' called for object Rails rake 任务在生产中失败:“NoMethodError:为 URI:Module 调用私有方法‘open’” - Rails rake task fails just in production: "NoMethodError: private method `open' called for URI:Module" 如果应用 -m 模板,Rails 新命令将失败:“NoMethodError: private method `open' called for URI:Module” - Rails new command fails if -m template is applied: "NoMethodError: private method `open' called for URI:Module" 载波:NoMethodError-#的未定义方法“ permit” <ActionDispatch…> - Carrierwave: NoMethodError - undefined method `permit' for #<ActionDispatch…> #的未定义方法“ to” - undefined method `to' for #<ActionDispatch::Routing::Mapper: (NoMethodError) 调用Refinery :: Admin :: PagesController:Class的私有方法“ prepend”(NoMethodError) - private method `prepend' called for Refinery::Admin::PagesController:Class (NoMethodError) NoMethodError:为类调用了私有方法“ existence_check” - NoMethodError: private method `existence_check' called for Class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM