【问题标题】:cannot run rails g mongoid:config command .>>undefined method error无法运行 rails g mongoid:config 命令。>>未定义的方法错误
【发布时间】:2016-09-05 21:25:44
【问题描述】:

我在 windows 7 32bit 上运行此命令时遇到问题,尽管它在实践作业之前有效-令人惊讶的是,它现在给了我错误。

我只创建了一个新应用程序,将 mongoid 添加到 gem 文件并运行了 bundle ,但是在运行 rails g mongoid:config 时它给了我错误

error log

这是我的 gemfile

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]

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

【问题讨论】:

    标签: ruby-on-rails ruby windows mongodb mongoid


    【解决方案1】:

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

    使用 Ruby 2.4 时,可以在调用 to_time 时保留接收方的时区。

    但这是 Rails 5 的一项功能,但您运行的是 4.2.4。不知何故 ActiveSupport.to_time_preserves_timezoneis set ,即在初始化程序中。尝试将其设置为 false。尝试找到并删除它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多