Skip to content

Commit

Permalink
Fix relationship rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklandgrebe committed Sep 27, 2017
1 parent be8fb2f commit 09596bf
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/caprese/adapter/json_api/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,14 @@ def data_for(association)
end

def data_for_one(association)
if association.belongs_to? &&
parent_serializer.object.respond_to?(association.reflection.foreign_key)
id = parent_serializer.read_attribute_for_serialization(association.reflection.foreign_key)
type = association.reflection.type.to_s
ResourceIdentifier.for_type_with_id(type, id, serializable_resource_options)
# TODO(BF): Process relationship without evaluating lazy_association
serializer = association.lazy_association.serializer
if (virtual_value = association.virtual_value)
virtual_value
elsif serializer && association.object
ResourceIdentifier.new(serializer, serializable_resource_options).as_json
else
# TODO(BF): Process relationship without evaluating lazy_association
serializer = association.lazy_association.serializer
if (virtual_value = association.virtual_value)
virtual_value
elsif serializer && association.object
ResourceIdentifier.new(serializer, serializable_resource_options).as_json
else
nil
end
nil
end
end

Expand Down

0 comments on commit 09596bf

Please sign in to comment.