The Issue
I noticed that the item relation attributes are not being serialized in this gem, just the :id and :type keys are being serialized for the relations. Take in mind that I'm talking about the item's relation(s), not about the item itself that is being serialized.
How can we serialize the attributes of the item relations in this gem?
Is there an option for that already?
# .../app/serializers/attachment_serializer.rb
class AttachmentSerializer
include JSONAPI::Serializer
attributes :id, :name
belongs_to :project
end
# .../app/serializers/project_serializer.rb
class ProjectSerializer
include JSONAPI::Serializer
attributes :id, :name, :active
has_many :users
end
attachment = Attachment.last
AttachmentSerializer.new(attachment).serializable_hash
⚠️ this is not displaying either project's name and active attributes after the serialization.
Expected Behavior
{:id=>"637cf4d769ca9c09a5f6a0d8",
:type=>:attachment,
:attributes=>
{:id=>BSON::ObjectId('637cf4d769ca9c09a5f6a0d8'),
:name=>"PostMan Tutorial",},
:relationships=>
{:project=>{:data=>{:id=>BSON::ObjectId('641d2f6c69ca9c0f54edfb10'),
:name=>"Project with Sheet View",
:active=>true}}
Actual Behavior
{:id=>"637cf4d769ca9c09a5f6a0d8",
:type=>:attachment,
:attributes=>
{:id=>BSON::ObjectId('637cf4d769ca9c09a5f6a0d8'),
:name=>"PostMan Tutorial",},
:relationships=>
{:project=>{:data=>{:id=>"62ed6a75a6af03010ff96521"}}
Specifications
- Version: 2.2.0
- Ruby version: 3.2.2
The Issue
I noticed that the item relation attributes are not being serialized in this
gem, just the:idand:typekeys are being serialized for the relations. Take in mind that I'm talking about the item's relation(s), not about the item itself that is being serialized.How can we serialize the attributes of the item relations in this gem?
Is there an option for that already?
nameandactiveattributes after the serialization.Expected Behavior
Actual Behavior
Specifications