Reputation: 1195
I have a basic Rails 7 application that uses the jsonapi-resources
gem. On the Rails side of the application, I implemented a simple structure of two resources - events
and event_categories
. They are connected to each other through associations:
has_one :category, class_name: "EventCategory", exclude_links: %i[self related]
has_many :events
Everything works successfully through Postman. include
, fields[*]
and sorting work.
Well, that is, everything is fine with the Rails part.
The problem is only with Ember.
From their documentation, I conclude that Ember out of the box can work with JSON:API using the JSONAPIAdapter
. But I immediately get this error:
Error while processing route: events.index Assertion Failed: Missing Resource Type: received resource data with a type 'events' but no schema could be found with that name. Error: Assertion Failed: Missing Resource Type: received resource data with a type 'events' but no schema could be found with that name.
Uncaught (in promise) Error: Assertion Failed: Missing Resource Type: received resource data with a type 'events' but no schema could be found with that name.
// app/models/event.js
import Model, { attr } from '@ember-data/model';
export default class EventModel extends Model {
@attr('string') note;
@attr('string') scheduled_on;
}
Tell me, please, what is the problem?
Upvotes: 1
Views: 125
Reputation: 833
I had the same error, but after I created an ApplicationAdapter
and an ApplicationSerializer
it got solved.
import JSONAPIAdapter from '@ember-data/adapter/json-api';
export default class ApplicationAdapter extends JSONAPIAdapter {}
import JSONAPISerializer from '@ember-data/serializer/json-api';
export default class ApplicationSerializer extends JSONAPISerializer {}
Upvotes: 0