ruby-on-rails Mongoid - Rails -无法找到生成器'mongoid:config'

w8f9ii69  于 2023-10-21  发布在  Ruby
关注(0)|答案(1)|浏览(145)

我是Rails新手,正在尝试安装mongoid。我已经遵循了MongoDB documentation中提到的确切步骤,即:

  • gem install rails -v '~> 7'
  • rails new myapp --skip-active-record
  • cd myapp
  • 然后将gem 'mongoid'添加到我的Gemfile
  • 然后是bundle install

但我得到了以下错误:
找不到生成器“mongoid:”。
下面是我的Gemfile:

source "https://rubygems.org"

ruby "3.1.4"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.1"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"

# Add support for mongo
gem 'mongoid'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri windows ]
end

group :development do
  # Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"

  # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
  # gem "rack-mini-profiler"

  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"

  gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
end

group :test do
  # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
  gem "capybara"
  gem "selenium-webdriver"
end

有办法解决吗?
谢谢你,

dm7nw8vv

dm7nw8vv1#

作为Rails的新手,我被Mongo文档中显示的9.0版本所误导。
当前版本的mongoid(8.1.2)只支持Rails 7.0.x,还不支持7.1。
我将Rails降级到7.0.8,并从头开始重新启动这个过程。
现在一切都正常了。

相关问题