Mongoid - Rails - 找不到生成器“mongoid:config”

问题描述 投票:0回答:1

我是 Rails 新手,正在尝试安装

mongoid
。 我已按照MongoDB文档中提到的确切步骤进行操作,即:

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

但我收到以下错误:

找不到生成器“mongoid:config”。

这是我的 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

知道如何解决这个问题吗?

谢谢,

ruby-on-rails rubygems mongoid
1个回答
0
投票

作为 Rails 新手,我被表明 9.0 版本可用的 Mongo 文档稍微误导了。

当前版本的 mongoid (8.1.2) 仅支持 Rails 7.0.x,尚不支持 7.1。

我将 Rails 降级到 7.0.8 并从头开始重新启动该过程。

现在一切正常 ✅

© www.soinside.com 2019 - 2024. All rights reserved.