Quote Rails Tutorial
First move to the working directory
Command execution after moving
$ rails generate controller <Controller name> <Action name> <Action name>・ ・ ・ #Example $ rails generate controller StaticPages home help
If you execute the above command
・ Creating a controller -Routing settings -Creating a view file It is very convenient and easy because it automatically creates!
In fact, you can make a page with just this.
For example, when you want to create a new about page, you can add it by manually creating a file or writing code.
① Routing settings ② Add action to the controller ③ Create view file
Rails.application.routes.draw do get 'static_pages/home' get 'static_pages/help' get 'static_pages/about'← Add end
class StaticPagesController < ApplicationController def home end def help end def about ← added end ← added end
③ Create view file Right-click on about.html.erb in app/views/static_pages to create a new one
<h1>Create About</h1> ・ ・ ・ ・ ・ ・ ・ ・ ・
This completes the page addition.
The URL can be opened on the web by adding static_pages/about at the end. (https://~~~/static_pages/about)