繁体   English   中英

为什么这个mongoid Rails 3项目中没有rake任务?

[英]Why are there no rake tasks in this mongoid Rails 3 project?

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

上面的公共回购是我们正在为奥斯汀社区花园工作的社区编码项目,到目前为止这是一个相当简单的项目,但由于某种原因, rake db:seed不起作用(“不知道如何构建任务db:seed“),当你运行rake -T它根本没有显示任何 rake任务。

MongoID文档说它提供了大多数与DB相关的常见rake任务 - 我无法弄清楚为什么它们不在那里。

我和Rails 3.X有类似的问题,虽然mongoid Gem包含在我的Gemfile中。 我可以通过明确要求mongoid gem中的database.rake文件来解决问题。 我在我的Rakefile中添加了这两行:

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

这对我行得通。

有完全相同的问题。

意识到我从未在我的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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM