Need help with ember-data-route?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

128 Stars 11 Forks MIT License 53 Commits 6 Opened issues


Common teardown scenario for ember routes backed by a data model

Services available


Need anything else?

Contributors list

Ember Data Route Build

ember-data-route is built and maintained by DockYard, contact us for expert Ember.js consulting.


Ensure you clean up after your models.

Any routes you deactivate will check the

to ensure it is not unsaved. If it is it will either rollback or remove the model from the store depending if has been previously persisted.


npm install ember-data-route --save-dev


Add the mixin to any route you want:

import Ember from 'ember';
import DataRoute from 'ember-data-route';

export default Ember.Route.extend(DataRoute, { ... });

Transition Confirmation

By default when you transition out of the route the data model is rolled-back/removed automatically after the router is deactivated. However, you may want to detect if this is going to happen and alert the user of changes that will be lost. Typically you could use

to allow the user to decide to proceed or not. In the route you are mixing into you can provide your own
function to handle this. By default this function returns
and is passed the
object as an argument for you to handle. One possible override could be:
export default Ember.Route.extend(DataRouteMixin, {
  willTransitionConfirm() {
    return window.confirm("You have unsaved changes that will be lost. Do you want to continue?");

Configuring Which Model


isn't the place where your primary model is located, so setting
to something else would allow you to override that setting.
export default Ember.Route.extend(DataRouteMixin, {
  primaryModel: 'user'

This will look on

, instead of


We are very thankful for the many contributors


This library follows Semantic Versioning

Want to help?

Please do! We are always looking to improve this gem. Please see our Contribution Guidelines on how to properly submit issues and pull requests.


DockYard, Inc © 2014


Licensed under the MIT license

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.