I'm attempting to add some actions to the nested route of Publishables
in Ember:
Router.map(function() {
this.resource('publishables', {path: '/publishables'}, function() {
this.resource('publishable', { path: ':publishable_id' });
});
});
export default Router;
The Publishables
route:
export default Ember.Route.extend({
model: function(params) {
return this.store.find('publishable', { page: params.page });
}
});
The Publishables
model:
export default DS.Model.extend({
title: DS.attr(),
description: DS.attr(),
authors: DS.hasMany('author', { async: true }),
category: DS.belongsTo('category', { async: true }),
published: DS.attr(),
publish_from: DS.attr(),
slug: DS.attr(),
contentType: DS.attr()
});
The Publishables
controller:
export default Ember.ArrayController.extend({
actions : {
preview: function(id) {
this.transitionToRoute('publishable', id);
}
}
});
And the Publishables
template:
<h2>Publishables</h2>
{{#each}}
<p {{action "preview" id}}>{{title}}</p>
{{/each}}
{{outlet}}
This works wonderfully. If I click the {{title}}
, it transitions to publishable/:id
and the appropriate data is loaded in the {{outlet}}
.
Now I would like to add some actions to Publishable
. If I create a Publishable
controller much like the Publishables
controller, everything breaks. I believe this is due to Publishable
being a child of Publishables
. Can anyone steer me in to the right direction on how to get actions bound in the nested route?