0
나는 Rails와 Ember.js에서 앱을 만들고 있습니다.Ember.js 동일한 모델을 반환
모델/post.js
App.Post = DS.Model.extend({
title: DS.attr('string'),
param: DS.attr('string')
});
루트/posts.js
App.PostsIndexRoute = Em.Route.extend({
model: function() {
return this.store.findQuery('post');
}
});
// Esto hace falta?
App.PostsShowRoute = Em.Route.extend({
serialize: function(model) {
return {
post_id: model.get('param')
};
}
});
router.js
App.Router.reopen({
location: 'history'
});
App.Router.map(function() {
this.resource('posts', function() {
return this.route('show', {
path: '/:post_id'
});
});
});
store.js
App.Store = DS.Store.extend({
adapter: DS.RESTAdapter.reopen({
namespace: 'api'
})
});
: 나는 다음과 같은이
템플릿/posts.hbs
{{outlet}}
템플릿/글/index.hbs
<ul>
{{#each controller}}
<li>{{#linkTo "posts.show" this}}{{title}}{{/linkTo}}</li>
{{/each}}
</ul>
내가 방문 로컬 호스트 : 3000/게시물 나는 글과 목록을 , 내 데이터베이스가 7 게시물이 있습니다, 이보기에서 ember.js는 7 (li) 요소를 보여 주지만 마지막 요소는 표시합니다.
내 데이터베이스가 있습니다
어떤 생각 post7, post7, post7, post7, post7, post7, post7 : post1, POS2, 포스트 3, post4, post5, post6, post7 보기 쇼를?
이 문제를 해결할 수 있습니까? –
@ MárcioRodriguesCorreaJúnior이 코드를 사용하고 있습니다 : https://github.com/heartsentwined/ember-auth-rails-demo – ie8888