Skip to content

Instantly share code, notes, and snippets.

@RossValler
Last active October 12, 2018 18:17
Show Gist options
  • Save RossValler/16d9be91b310fe01ecbdc152e8aae292 to your computer and use it in GitHub Desktop.
Save RossValler/16d9be91b310fe01ecbdc152e8aae292 to your computer and use it in GitHub Desktop.
Link-to Model not Working
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
// Broken on 2.10.2
// Works as expected on 2.9.1
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
name: attr('string'),
invoices: hasMany('invoice')
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
number: attr('string'),
client: belongsTo('client')
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('single', {path: '/:id'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(){
var client = this.store.createRecord('client', {name: 'Ross'});
this.store.createRecord('invoice', {number: 'R0001', client: client});
this.store.createRecord('invoice', {number: 'F0002', client: client});
return this.store.peekAll('invoice');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<div class="row">
{{#each model as |invoice|}}
{{#link-to "single" invoice.client}}
{{invoice.number}}: {{invoice.client.name}}
{{/link-to}}<br/>
{{else}}
No clients to show
{{/each}}
</div>
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment