Junior Track Roadmap

Layout namespacing

This course follows how a Rails app decides which layout wraps each page. Public pages render inside application.html.erb, and every page under /admin renders inside admin.html.erb. The switch is one line, layout "admin", in Admin::BaseController. The lessons read the installed ActionView::Layouts source to show how nested Admin:: controllers inherit that value through class_attribute. They also show how controllers with no layout call fall back to application.html.erb by convention. Finally, they compare both layout files line by line and cover the Symbol, Proc and render layout: false forms.

What you'll learn

  • ✓What the layout class method does and where it is declared
  • ✓How class_attribute passes a layout down to nested Admin:: controllers
  • ✓How Rails finds application.html.erb when no layout is declared
  • ✓The differences and shared partials between the public and admin layouts
  • ✓Symbol and Proc layouts, and render layout: false for a single action
Free preview · Lesson 1 2 min read

Two layouts, one line that switches between them

app/views/layouts/application.html.erb and app/views/layouts/admin.html.erb. Every public page, such as the roadmap, a course or a lesson, is wrapped in the first. Every page under /admin, such as the dashboard or the course editor, is wrapped in the second: a sidebar-driven layout with no navbar…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...