After moving to the directory you want to create
rails new [app name] -d mysql
Specify mysql when creating database with "-d mysql"
Move to the created app directory. The following command will create the database according to the settings described in database.yml.
If it doesn't work as expected, check database.yml. Since sqlite is specified in the initial database, if necessary, write mysql in gem and bundle install.
rails g controller [Controller name]
root "[Controller name]#index"
When root accesses with url, the controller and action displayed on the top page are displayed. This time, the [index] action is specified.
I will describe the necessary actions.
def index end
Since the [app/views/controller name /] directory has been created, create the index.html.erb file.
Here, when you start the rails server and access it locally, "Hello, World!" Is displayed.
rails g model [Model name]
When you create a model, a migration file for creating a table is automatically generated. Describe the migration file and execute the migration file.