【问题标题】:Error uninitialized constant ActiveSupport::EventedFileUpdateChecker错误未初始化常量 ActiveSupport::EventedFileUpdateChecker
【发布时间】:2019-02-22 16:54:22
【问题描述】:

执行此命令时出现此错误

rails 生成模型

根据this 的帖子,我有这个错误是因为在 Rails 5 中引入了 EventedFileUpdateChecker,但是该项目是在 Rails 5 中创建的,当我在控制台中输入 rails -v 时它会输出这个

导轨 5.0.0.1

如果我运行这个命令

rails 生成 whatever

在一个新项目中我得到同样的错误

来源'https://rubygems.org'

这是我的 Gemfile

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '= 5.0.0.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.11.4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'figaro'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# Bootstrap gem
gem 'bootstrap-sass', '~> 3.2.0'
gem 'bootstrap-sass-extras'
gem 'autoprefixer-rails'
gem 'bootstrap-select-rails'
gem 'bootstrap_form'

# Reset css
gem 'normalize-rails'

# Authentication
gem 'devise'
gem "devise_ldap_authenticatable", '<= 0.8.5'

# Internationalization
gem 'rails-i18n'

# Runtime developer console
gem 'pry'

# Read cvs or excel files
gem 'roo'
gem "iconv"

# Generate Excel files
gem 'zip-zip'
gem 'axlsx', '~> 2.0.1'
gem 'axlsx_rails'

# JQuery validates
gem "jquery-validation-rails"

#Generates documentation
gem 'apipie-rails'

gem 'popper_js', '~> 1.14.5'
gem 'turbolinks', '~> 5.2.0'
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'

# Responsive tables
source 'https://rails-assets.org' do
  gem 'rails-assets-johnpolacek--stacktable.js'
end

# Paginate
# gem 'will_paginate', '~> 3.1.0'

如果我评论这一行

  config.file_watcher = ActiveSupport::EventedFileUpdateChecker

它有时会卡住,我必须关闭终端,有时它会输出:

警告:运行 gem pristine --all 以重新生成已安装的 gemspecs(如果你使用 bundle --path 则删除然后重新安装你的包)将提高 Spring 的启动性能。 警告:运行gem pristine --all 来重新生成已安装的gemspecs(如果您使用bundle --path,则删除然后重新安装您的包)将提高Spring 的启动性能。 /usr/lib/ruby/vendor_ruby/sprockets/digest_utils.rb:47:警告:常量 ::Fixnum 已弃用 /usr/lib/ruby/vendor_ruby/sprockets/digest_utils.rb:51:警告:常量 ::Bignum 已弃用 /usr/lib/ruby/vendor_ruby/sprockets/processor_utils.rb:110:警告:常量 ::Fixnum 已弃用 /usr/lib/ruby/vendor_ruby/sprockets/processor_utils.rb:111:警告:常量 ::Bignum 已弃用 回溯(最近一次通话最后): -e: nil:NilClass (NoMethodError) 的未定义方法“first”

【问题讨论】:

  • 你跑gem pristine --all了吗?
  • 您会升级您的rails 版本并再次尝试bundle install 吗?
  • 我试过这样做,但我得到了同样的错误。
  • 你试过bundle exec rails generate ...吗?
  • 您是否命名了您正在生成的模型? rails generate model Users 等?

标签: ruby-on-rails ruby rubygems


【解决方案1】:

我解决了,我重新安装了 ruby​​ 和 bundler,它又可以工作了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    • 2011-07-30
    • 2012-01-21
    • 1970-01-01
    • 2011-07-07
    • 1970-01-01
    • 2011-10-17
    相关资源
    最近更新 更多