ruby on rails - How translate serialize type with dash to model slashed structure? -
my api in rails ams (json:api) return serializer type name dash (artemis-forum-disputes
), inside frontend app, uses ember, store models subdirectory structure (artemis/forum/disputes
).
warning: encountered resource object type "artemis-forum-disputes", no model found model name "artemis-forum-dispute" (resolved model name using 'apollo-enterprise@serializer:application:.modelnamefrompayloadkey("artemis-forum-disputes")').
how solve this? thanks.
you can tell ember data model use overriding modelnamefrompayloadtype method on serializer. if override method in application serializer , have transform dashes slashes ember should able find models in subdirectory.
// app/serializers/application.js // or app/application/serializer.js import ds 'ember-data' export default ds.jsonapiserializer.extend({ modelnamefrompayloadtype(payloadtype) { return payloadtype.replace(/-/g, '/'); } });
Comments
Post a Comment