File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,16 +353,14 @@ def related_link(source, relationship)
353353 end
354354
355355 def to_one_linkage ( source , relationship )
356- linkage = { }
357356 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?
358359
359- if linkage_id
360- linkage [ :type ] = format_key ( relationship . type_for_source ( source ) )
361- linkage [ :id ] = linkage_id
362- else
363- linkage = nil
364- end
365- linkage
360+ {
361+ type : linkage_type ,
362+ id : linkage_id ,
363+ }
366364 end
367365
368366 def to_many_linkage ( source , relationship )
@@ -390,7 +388,9 @@ def to_many_linkage(source, relationship)
390388 end
391389
392390 linkage_types_and_values . each do |type , value |
393- linkage . append ( { type : format_key ( type ) , id : @id_formatter . format ( value ) } )
391+ if type && value
392+ linkage . append ( { type : format_key ( type ) , id : @id_formatter . format ( value ) } )
393+ end
394394 end
395395 linkage
396396 end
You can’t perform that action at this time.
0 commit comments