Junior Track Roadmap

Namespaced controllers

This course reads the admin and execution routes of one Rails app and traces each to its controller file. It shows how namespace :admin do ... end adds a URL prefix and an Admin:: module, and how nested namespaces add one segment and one module level per block. It covers the module: option, scope module: combined with shallow: true, and the explicit to: "path#action" form. It also shows a three-level execution/api/v1 namespace and separates namespacing from class inheritance. A plain Ruby challenge closes it.

What you'll learn

  • ✓How namespace blocks add a URL prefix and a controller module
  • ✓How nested namespaces grow the URL and module one level at a time
  • ✓How module: and scope module: change the controller path without changing the URL
  • ✓How shallow: true drops a parent prefix from member action URLs
  • ✓How to: "path#action" names a controller and action explicitly, with constraints: for filenames
  • ✓Why namespace nesting and class inheritance are separate decisions
Free preview · Lesson 1 3 min read

What namespace :admin do ... end generates

This app's config/routes.rb opens its admin section with:

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...