fast_jsonapi icon indicating copy to clipboard operation
fast_jsonapi copied to clipboard

Compound documents not showing up

Open itsameandrea opened this issue 6 years ago • 3 comments

Hey there guys.

I've been trying to use the compound document serialization, but for some reason things aren't working.

I have a number of models that are being serialized by the gem. This is what they look like:

class Shift < ApplicationRecord
  belongs_to :team, optional: true
  ...
class Team < ApplicationRecord
  has_many :shifts
  ...

This is what the serializer looks like

class ShiftSerializer
  include FastJsonapi::ObjectSerializer
  ...
  belongs_to :team
  ...
end

The serialization works. However, even though I am including the compound team document:

def index
  shifts = policy_scope(Shift)
  options = {}
  options[:include] = [:team, :'team.name', :'team.color']
  render json: ShiftSerializer.new(shifts, options)
end

I'm still getting the object formatted like so:

...
relationships: {
  team: {
    data: {
      id: "22",
      type: "Team"
    }
  }
}

Whereas I'm expecting to get also the attributes of my team model.

itsameandrea avatar Apr 21 '19 20:04 itsameandrea

Did you find a fix for this?

1dolinski avatar Jun 26 '19 15:06 1dolinski

Having this exact issue myself... hopefully I can find a fix.

rob-lane avatar Aug 16 '19 03:08 rob-lane

It seems Netflix has abandoned this project. The community created a new fork to continue supporting this project. Please refer https://github.com/fast-jsonapi/fast_jsonapi

kapilnarula avatar Oct 19 '19 06:10 kapilnarula