4

https://github.com/memphis518/Garden-Dating-Service

上面的公共 repo 是我们正在为 Austin Community Gardens 开发的社区编码项目,到目前为止它是一个相当简单的项目,但由于某种原因rake db:seed不起作用(“不知道如何构建任务 db:seed” ),当你运行rake -T它时,它根本没有显示任何rake 任务。

MongoID 文档说它提供了大多数常见的与 DB 相关的 rake 任务——我不知道为什么它们不存在。

4

2 回答 2

6

我在使用 Rails 3.X 时遇到了类似的问题,尽管我的 Gemfile 中包含了 mongoid Gem。我可以通过明确要求 mongoid gem 中的 database.rake 文件来解决这个问题。我将这 2 行添加到我的 Rakefile 中:

spec = Gem::Specification.find_by_name 'mongoid'
load "#{spec.gem_dir}/lib/mongoid/railties/database.rake"

这对我行得通。

于 2014-06-26T13:38:37.010 回答
3

有完全相同的问题。

意识到我从未在我的 Gemfile 中添加“mongoid”。这修复了它:

gem 'mongoid'

它将添加这些 rake 任务:

rake db:drop                    # Drops all the collections for the database for the current Rails.env
rake db:mongoid:create_indexes  # Create the indexes defined on your mongoid models
rake db:mongoid:drop            # Drops the database for the current Rails.env
rake db:mongoid:remove_indexes  # Remove the indexes defined on your mongoid models without questions!
rake db:reseed                  # Delete data and seed
rake db:seed                    # Load the seed data from db/seeds.rb
rake db:setup                   # Create the database, and initialize with the seed data
于 2012-08-05T19:48:19.333 回答