home
  • Blog
1.10
  • Getting Started
  • Getting Ember
  • Concepts
  • The Object Model
  • Application
  • Templates
  • Routing
    • Introduction
    • Defining Your Routes
    • Generated Objects
    • Specifying a Route's Model
    • Setting Up a Controller
    • Rendering a Template
    • Redirecting
    • Specifying the URL Type
    • Query Parameters
    • Asynchronous Routing
    • Loading / Error Substates
    • Preventing and Retrying Transitions
  • Components
  • Controllers
  • Models
  • Views
  • Enumerables
  • Testing
  • Configuring Ember.js
  • Cookbook
  • Understanding Ember.js
  • Contributing to Ember.js
Old Guides - You are viewing the guides for Ember v1.10.0.
Go to v5.0.0

Generated Objects

Edit pencil

As explained in the routing guide, whenever you define a new route, Ember.js attempts to find corresponding Route, Controller, View, and Template classes named according to naming conventions. If an implementation of any of these objects is not found, appropriate objects will be generated in memory for you.

Generated routes

Given you have the following route:

App.Router.map(function() {
  this.resource('posts');
});

When you navigate to /posts, Ember.js looks for App.PostsRoute. If it doesn't find it, it will automatically generate an App.PostsRoute for you.

Custom Generated Routes

You can have all your generated routes extend a custom route. If you define App.Route, all generated routes will be instances of that route.

Generated Controllers

If you navigate to route posts, Ember.js looks for a controller called App.PostsController. If you did not define it, one will be generated for you.

Ember.js can generate three types of controllers: Ember.ObjectController, Ember.ArrayController, and Ember.Controller.

The type of controller Ember.js chooses to generate for you depends on your route's model hook:

  • If it returns an object (such as a single record), an ObjectController will be generated.
  • If it returns an array, an ArrayController will be generated.
  • If it does not return anything, an instance of Ember.Controller will be generated.
Custom Generated Controllers

If you want to customize generated controllers, you can define your own App.Controller, App.ObjectController and App.ArrayController. Generated controllers will extend one of these three (depending on the conditions above).

Generated Views and Templates

A route also expects a view and a template. If you don't define a view, a view will be generated for you.

A generated template is empty. If it's a resource template, the template will simply act as an outlet so that nested routes can be seamlessly inserted. It is equivalent to:

{{outlet}}
left arrow
Defining Your Routes
Specifying a Route's Model
right arrow
On this page

  • Generated routes
  • Custom Generated Routes
  • Generated Controllers
  • Custom Generated Controllers
  • Generated Views and Templates
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2023 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue