Hi,
I’m currently working on a todoApp using Rails API as backend and EmbersJs as front. I want everything to be displayed on the rootURL.
I got this error from my firefox console : Encountered “1” in payload, but no model was found for model name “1” (resolved model name using (unknown).modelNameFromPayloadKey(“1”)).
I dont understand where that could come from.
here’s my app/models/todo.js
:
import DS from ‘ember-data’;
export default DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
});
my app/routes/application.js
:
import Route from '@ember/routing/route';
export default Route.extend({
model(){
return this.store.findAll('todo')
}
});
And my app/templates/application.hbs
:
<h1>Test micro</h1>
<ul>
{{#each model as |todo|}}
<li>{{todo.title}} Fait ? :{{todo.isCompleted}}</li>
{{/each}}
</ul>
{{outlet}}
my rails-api/serializers/todo_serializer.rb
:
class TodoSerializer < ActiveModel::Serializer
attributes :id, :title, :isCompleted
end
my `rails-api/controllers/todos_controller.rb:
class TodosController < ApplicationController
def index
render json: Todo.all
end
end
and my rails-api/models/todo
class Todo < ActiveRecord::Base
end
As i’m new on Ember, maybe am i looking at the wrong place, but if someone have an idea, that would be awesome ! If you need any further informations, just let me know.