Skip to content

Commit 61d46d8

Browse files
author
Chris Kolodin
committed
patch to serialize relationships w same foreign key
instead of fetching records using the foreign_key use the relationship name instead. the value stored in the map under the foreign key contains the records for the first relationship defined using that foreign key. by contrast using the relationship name returns the records fetched for the relationship defined with that name.
1 parent 2733ad8 commit 61d46d8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/jsonapi/resource_serializer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ def foreign_key_types_and_values(source, relationship)
318318
end
319319
end
320320
else
321-
source.public_send(relationship.foreign_key).map do |value|
322-
[relationship.type, @id_formatter.format(value)]
321+
source.public_send(relationship.name).map do |value|
322+
[relationship.type, @id_formatter.format(value.id)]
323323
end
324324
end
325325
end

0 commit comments

Comments
 (0)