0Pricing
Ruby Academy · Lesson

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"
end

All lessons in this course

  1. Routes and Resources
  2. Controllers and Actions
  3. Strong Parameters
  4. Views and Rendering
← Back to Ruby Academy