[RUBY] Resolve ActiveRecord :: NoDatabaseError when doing rails test (Rails tutorial Chapter 3)

Keep track of any errors that occur as you progress through the rails tutorial. The hardware uses MacBook Air, and the development environment uses VScode.

Rails Tutorial Chapter 3 3.3.1 First Test

Command to execute


$ rails test

Error that occurs


$ rails test
~abridgement~
~abridgement~ FATAL:  database "tutorial_test" does not exist (ActiveRecord::NoDatabaseError)

This is ** no database! The error is **. When you do rails test, you also need to create a database for ** testing. ** **

Solution Generate a database

Therefore, generate a database with the command.

Command to run to generate the database


$ rails db:create

By the way

$ rake db:create

 But you can. You can refer to this article for this. [What is Rails rake? ](Https://qiita.com/SuguruOoki/items/e736b15bbb80eacf66d7)

 This command will generate a database according to the contents of config / database.yml.


#### **`Execution result`**
```python

$ rails db:create

Created database 'app name_development'
Created database 'app name_test'

If you see this, you have successfully generated the database.

At this point, the $ rails test should pass correctly!

If you find it useful, I would be grateful if you could click the ** LGTM button. ** ** Let's do our best to learn Rails together! : raised_hand_tone1:

Recommended Posts

Resolve ActiveRecord :: NoDatabaseError when doing rails test (Rails tutorial Chapter 3)
Resolve ActiveRecord :: NoDatabaseError on rails6
Resolve Gem :: FilePermissionError when running gem install rails (Rails Tutorial Chapter 1)
rails tutorial Chapter 6
Rails tutorial test
rails tutorial Chapter 1
rails tutorial Chapter 7
rails tutorial Chapter 5
rails tutorial Chapter 9
rails tutorial Chapter 8
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Rails Tutorial Chapter 3 Learning
Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 4 Learning
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Chapter 8 Notes
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Resolve LoadError (cannot load such file --bcrypt) that occurs in rails test (Rails tutorial Chapter 6)
[Rails Tutorial Chapter 4] Rails-flavored Ruby
Rails Tutorial Chapter 14 Creating Relationship Test Data with Factory Bot
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
[Rails Tutorial Chapter 5] Create a layout
rails tutorial chapter 10 summary (for self-learning)
Chewing Rails Tutorial [Chapter 2 Toy Application]
[Rails5] Rspec -Unit test when nesting-
Rails Tutorial (4th Edition) Memo Chapter 6
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 4
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
Rails Tutorial 6th Edition Learning Summary Chapter 5
How to resolve errors when installing Rails 5.1.3
Rails Tutorial 6th Edition Learning Summary Chapter 2
Rails Tutorial Chapter 0: Preliminary Basic Knowledge Learning 5
Rails Tutorial 6th Edition Learning Summary Chapter 3
Rails Tutorial 6th Edition Learning Summary Chapter 8
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
[Rails] ActiveRecord
I rewrote the Rails tutorial test with RSpec
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 6
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 3
Rails Tutorial Chapter 1 From Zero to Deployment [Try]
Chewing Rails Tutorial [Chapter 3 Creating Almost Static Pages]
[Rails tutorial] A memorandum of "Chapter 11 Account Activation"
I can't deploy! Resolve an error that can't be pushed to heroku (Rails Tutorial Chapter 1)