Ember JSONAPI resource custom relationship


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

Then in my Ember App, I have the following files:

  1. adapters/user.js
  2. models/users.js
  3. services/users.js
  4. adapters/loan-application.js
  5. models/loan-applications.js
  6. services/loan-applications.js
  7. 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.


I’m using the following versions: ember-cli 2.4.2 ember-jsonapi-resources: 1.1.0beta3