我是Ruby on Rails的新手.运行'bundle'命令进行更新/安装后,当我尝试执行rails s或rails g mongoid:config控制台返回此消息时,该消息以:
/home/myUser/proyect/config/environments/development.rb:50:in `block in <top (required)>': uninitialized constant ActiveSupport::EventedFileUpdateChecker (NameError)
Run Code Online (Sandbox Code Playgroud)
这是我的Gemfile(是的,我想使用MongoDB作为数据库):
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Mongoid as the database
gem 'mongoid', '~> 5.1.0'
# Use bson
gem 'bson_ext'
# Use Puma as the app server
gem 'puma', '~> 3.0'
#Use Haml for html
gem 'haml'
# 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.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5.x'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# 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]
Run Code Online (Sandbox Code Playgroud)
和config/environments/development.rb文件:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
Run Code Online (Sandbox Code Playgroud)
根据Rails更改日志,config.file_watcher已经引入了选项Rails 5.它允许您根据文件更改进行自动重新加载.此功能取决于listenergem,并且您已在gemfile中列出它.但对我来说似乎可疑的是你的Rails版本!
gem 'rails', '4.2.6'
# but rails 4 does not support that feature!
Run Code Online (Sandbox Code Playgroud)
看起来你有一个development.rb从另一个版本的Rails框架,另一个项目复制的Gemfile(或配置?) ,或者手动将你的gemfile版本改为不适当的状态.
我建议你的两个选择是:
要将rails gemfile版本更改为最先进的版本,如下所示:
gem 'rails', github: 'rails/rails'
Run Code Online (Sandbox Code Playgroud)
而bundle一次;
config.file_watcher从配置文件中删除行.
通常会发生这种情况,因为您安装的 Rails 版本比您的.railsrc或template.rb.
如果是这种情况,当您运行 时rails new my_new_app,默认情况下将最新版本用于该过程的早期步骤,但一旦安装了 template/railsrc 版本,后面的步骤将使用该版本。这会导致兼容性问题。
rails -v您可以通过将(在您调用的目录中)的输出与您的或rails new中的内容进行比较来验证这是否是您的问题。如果它们不同,有一个简单的修复方法:.railsrctemplate.rb
.railsrc重新创建您的 Rails 应用程序,从您的或template.rb在命令行调用中指定相同的 Rails 版本:
rails _4.2.5.1_ new my_new_app
| 归档时间: |
|
| 查看次数: |
9885 次 |
| 最近记录: |