Skip to content

Commit ea8bb3c

Browse files
committed
test presence (catch empty strings too) of linkage_id and linkage_type
1 parent 49c8bc6 commit ea8bb3c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/jsonapi/resource_serializer.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,10 @@ def related_link(source, relationship)
353353
end
354354

355355
def to_one_linkage(source, relationship)
356-
return unless linkage_id = foreign_key_value(source, relationship)
357-
return unless linkage_type = format_key(relationship.type_for_source(source))
356+
linkage_id = foreign_key_value(source, relationship)
357+
linkage_type = format_key(relationship.type_for_source(source))
358+
return unless linkage_id.present? && linkage_type.present?
359+
358360
{
359361
type: linkage_type,
360362
id: linkage_id,

0 commit comments

Comments
 (0)