The purpose of this article is to roughly explain the procedure for creating an application in words. I created my study for my first time.
Execute the following command in the terminal. ・ Rails new (version specification) (database you want to specify) -Cd (created directory)
Execute the following command in the terminal. ・ Rails db: create ・ Rails s
If necessary, specify the Rails version and install the required Gem. After completion, do the following in your terminal as needed: ・ Bundle install ・ Bundle update
Do the following in your terminal: ・ Rails g model (model name)
Edit the migration file and describe the columns you want to create in the database. After completion, execute the following in the terminal. ・ Rails db: migrate
Make settings for each action according to the following flow. -Routing settings · Define controller creation or action · Creating a view
resources :Controller name, only[:action]
If you want to narrow down the action, describe it in the part inside only.
When creating a controller, write the following command in the terminal. ・ Rails g controller Controller name
Define the actions required for the controller. There are two points. -If you want to use the value obtained from the database in the view, assign the value to the instance variable and use it in the view. -Use strong parameters to save data.
The points are the following two points -Edit application.html.erb for header and footer layout. -For views for each action, create action name.html.erb in the views file and describe it.
Create an application according to the above flow.
Recommended Posts