Skip to content

Instantly share code, notes, and snippets.

@nizaroni
Created February 3, 2015 15:50
Show Gist options
  • Save nizaroni/ac5f89720fb300f409a7 to your computer and use it in GitHub Desktop.
Save nizaroni/ac5f89720fb300f409a7 to your computer and use it in GitHub Desktop.
Glossary of Rails terms for beginners.

Rails Glossary

A glossary of Rails terms for beginners.

Router

The router is the component of Rails that takes your config/routes.rb file, reads your routes from it and uses them to respond to incoming requests. If the requested URL is not defined in your routes, it will show a 404 page.

Route

A route is a URL that your Web application responds to. Examples might be / for the home page and /pizza for a pizza-related page.

Routes are defined in your config/routes.rb file. Each route you define needs to be associated to an HTTP verb, a controller and an action. The format for defining the controller and action is controller#action. For example:

get '/pizza' => 'food#pizza'

This route accepts GET requests to the /pizza URL. Such requests prompt Rails to call the pizza action on FoodController.

Controller

A controller is a class that is a collection of actions. Actions are just methods on the controller. A controller should group actions that are related. For example you might make a FoodController to group different actions related to foods. Controllers live in the app/controllers/ folder.

Action

An action is a controller's method that handles a request on a route. The kinds of requests that are handled by the action are defined in your config/routes.rb. An action decides what code to run for that route and how to respond.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment