I'm attempting to grab some data from my rails api and display it in the template. I'm very new to ember so the simpler the explanation the better and forgive me if this is a very stupid question. Any help would be greatly appreciated, I've been trying to get this working for hours.
Here is my template in jobs.hbs
{{#each job in model}}
<a href={{title}}>
<div class="info">
<div class="title">{{body}}</div>
</div>
</a>
{{/each}}
My route in routes/external/jobs.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.findAll('jobs');
}
});
My Jobs model in models/jobs.js
import DS from 'ember-data';
export default DS.Model.extend({
jobs: DS.hasMany('job')
});
My job model in models/job.js
import DS from 'ember-data';
export default DS.Model.extend({
title: DS.attr('string'),
id: DS.attr('string'),
});
My adapter in adapters/jobs.js
import ApplicationAdapter from './application';
export default ApplicationAdapter.extend({
primaryKey: '/jobs'
});
I am expecting my api to return data in the form
{
"jobs": [
{
id: "jfdsa132113",
title: "developer",
type: "Job",
body: "lorem ipsum",
tags: [
"some stuff",
"more stuff"
]
},
{
id: "jfdsa132113",
title: "developer",
type: "Job",
body: "lorem ipsum",
tags: [
"some stuff",
"more stuff"
]
}
]
}
Aucun commentaire:
Enregistrer un commentaire