Routes and Resources
RESTful routing.
What Is Routing?
Routing maps an incoming HTTP request (a method plus a path) to a controller action that handles it. The routes file is the front door of a Rails app.
- Routes live in
config/routes.rb. - Each route connects a URL to
controller#action. - Rails matches routes top to bottom.
A Basic Route
The simplest route maps a path to an action with get. Here a GET to /about calls the about action on PagesController.
Rails.application.routes.draw do
get "/about", to: "pages#about"
endAll lessons in this course
- Routes and Resources
- Controllers and Actions
- Strong Parameters
- Views and Rendering