Good day,
I have an Ember App that uses the ember-jsonapi-resource addon, with an RoR backend that uses a gem for json api resource server.
Now I have two models that are related as such:
The User model has a has_many relationship with my Application model; The Application model has a belongs_to relationship with my User model;
Now, I created a proxy relation in my UserResource called current_loan_application: See the code below
class UserResource < JSONAPI::Resource
has_one :current_loan_application, class_name: "LoanApplication", foreign_key_on: :related
end
Then in my Ember App, I have the following files:
- adapters/user.js
- models/users.js
- services/users.js
- adapters/loan-application.js
- models/loan-applications.js
- services/loan-applications.js
- services/current-loan-applications.js
Now in my the models/users.js, I have the following code:
import Ember from 'ember';
import Resource, { attr, hasOne, hasMany } from 'ember-jsonapi-resources/models/resource';
export default Resource.extend({
service: Ember.inject.service('users'),
currentLoanApplication: hasOne({ resource: 'current-loan-application', type: 'loan-applications' }),
})
My problem is that there’s an error where the current-loan-application has been removed and/or destroyed when it is being set, see the image:
I’m not sure what the problem is. Hopefully someone can help me.
Also:
I’m using the following versions: ember-cli 2.4.2 ember-jsonapi-resources: 1.1.0beta3