3
votes

I get the following error when I run rake db.seed, how can I fix it?

(I tried deleting seed.rb and recreating it, but it didn't work)

rake aborted! Don't know how to build task 'db.seed'

/Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task_manager.rb:62:in []' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:149:in invoke_task' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in block (2 levels) in top_level' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in each' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in block in top_level' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in run_with_threads' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in top_level' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in block in run' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in standard_exception_handling' /Users/user/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in run' /Users/user/.rbenv/versions/2.2.1/bin/rake:33:in `

Background information:

I am following a tutorial in which I have created a mock user in my db.seed file.

User.create! email: '[email protected]', password: 'password', password_confirmation: 'password'

Now when I run the command rake db:seed, I get the error above. How can I successfully run the command?

1
did you type rake db:seed or rake db.seed?rob
I was typing rake db.seed, gosh - thanks for pointing it out.Roy

1 Answers

8
votes

To avoid such errors in future, what you could do is, type bundle exec rake -T from the project directory to list all the available rake tasks for your Rails app:

➜  bundle exec rake -T
rake db:create                          # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databa...
rake db:drop                            # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in...
rake db:fixtures:load                   # Load fixtures into the current environment's database
rake db:migrate                         # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
rake db:migrate:status                  # Display status of migrations
rake db:rollback                        # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rake db:schema:cache:clear              # Clear a db/schema_cache.dump file
rake db:schema:cache:dump               # Create a db/schema_cache.dump file
rake db:schema:dump                     # Create a db/schema.rb file that is portable against any DB supported by AR
rake db:schema:load                     # Load a schema.rb file into the database
rake db:seed                            # Load the seed data from db/seeds.rb

Then, just copy the task that you are looking for (rake db:seed in this case) and run the rake task!