Intern Track Roadmap

ActionController: actions

This course covers Rails controller actions, using a real controller from this project. An action is an ordinary public method on a class that inherits from ApplicationController, matched by a route's controller#action string. The lessons explain the conventional names index, show, new and create, how instance variables carry data to the view, and how an action renders its template without a render call. They also introduce params and walk through a create action that saves a record, then redirects or re-renders the form with a 4xx status.

What you'll learn

  • ✓What a controller action is and how a route's controller#action points to it
  • ✓The meaning of the conventional action names index, show, new and create
  • ✓How instance variables hand data from an action to its view
  • ✓How implicit rendering picks the template named after the action
  • ✓How params holds values from dynamic segments and submitted forms
  • ✓How create saves, redirects on success and renders :new with unprocessable_content on failure
Free preview · Lesson 1 2 min read

What is a controller action?

Rails routes: basics ended with get "partners" => "public/pages#partners", as: :partners, naming a destination without opening it. Here is that destination in this project:

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...