不能 运行 rails g mongoid:config 命令。>>未定义的方法错误

cannot run rails g mongoid:config command .>>undefined method error

我在 windows 7 32 位上遇到了问题 运行 这个命令,虽然它在实践作业之前有效 - 令人惊讶的是,它现在给了我错误。

我只创建了一个新应用程序,将 mongoid 添加到 gem 文件和 运行 包中,但是当 运行 rails g mongoid:config

error log

这是我的 gem 文件

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# 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
gem 'mongoid', '~> 5.0.0'
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'
end

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

请,如果您需要更多信息,请发表评论。我搜索过类似的问题,但没有解决方案

http://guides.rubyonrails.org/upgrading_ruby_on_rails.html (2.19.8) 上写着

When using Ruby 2.4, you can preserve the timezone of the receiver when calling to_time.

但这是 Rails 5 功能,但您是 运行 rains 4.2.4。 ActiveSupport.to_time_preserves_timezone 以某种方式设置,即在初始化程序中。尝试将其设置为 false。尝试找到并删除它。