Why is there no rake task in this mongoid Rails 3 project?

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

The public repo above is the community coding project we're working on for Austin Community Gardens, and it's a pretty simple project, but for some reason rake db:seed doesn’t work ("I don’t know how to build task db: seed"), and when running rake -T it does not detect any rake tasks at all.

The MongoID documentation says that it provides most of the common DB related tasks - I can't understand why they are not there.

+4
source share
2 answers

I had a similar problem with Rails 3.X, although the mangooid Gem was included in my Gemfile. I could solve the problem by explicitly requiring a database.rake file from a mangooid gem. I added these 2 lines to my Rakefile:

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

This works for me.

+6
source

Had the same problem.

I realized that I never added "mongoid" to my Gemfile. This fix is:

 gem 'mongoid' 

He will add these rake tasks:

 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 
+3
source

All Articles