⚠️ This is how to add a page without any interaction with the model.
Create a route 🛤️
- Go to config > routes.rb file
- In the Rails.application.routes.draw method, enter a route using the syntax: [request type] "[URL]", to: "[controller]#[action]"
Create a controller 👨✈️
- Go to app > controllers folder
- Create a file named [route]_controller.rb, e.g. about_controller.rb
- Create a class named [Route]Controller and inherit from ApplicationController
- Define a method named [action from routes.rb], e.g. index
Create a view 🏞️
- Go to app > views folder
- Create a folder named [route]
- In that folder create a file named [action.html.erb]
- Add HTML (and ERB)
View new page 👀
- Go to http://localhost:3000/about
You’ll see the new page
Open Web Inspector
👀 You’ll see the request from the browser and the response from the server for the GET request to the /about URL.
View the page’s source code
👀 You’ll see the content that Rails added code from app > views > layouts > application.html.erb and inserted the code from index.html.erb inside the <%= yield => ERB tag.