Skip to content

Commit ebe0a37

Browse files
committed
Merge pull request #574 from arnt/master
Half-new relationship option: always_include_linkage_data
2 parents bd3a389 + 1edd559 commit ebe0a37

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ The relationship methods (`relationship`, `has_one`, and `has_many`) support the
450450
* `acts_as_set` - allows the entire set of related records to be replaced in one operation. Defaults to false if not set.
451451
* `polymorphic` - set to true to identify relationships that are polymorphic.
452452
* `relation_name` - the name of the relation to use on the model. A lambda may be provided which allows conditional selection of the relation based on the context.
453+
* `always_include_linkage_data` - if set to true, the relationship includes linkage data. Defaults to false if not set.
453454

454455
`to_one` relationships support the additional option:
455456
* `foreign_key_on` - defaults to `:self`. To indicate that the foreign key is on the related resource specify `:related`.

lib/jsonapi/resource_serializer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def link_object_to_one(source, relationship, include_linkage)
278278
end
279279

280280
def link_object_to_many(source, relationship, include_linkage)
281+
include_linkage = include_linkage | relationship.always_include_linkage_data
281282
link_object_hash = {}
282283
link_object_hash[:links] = {}
283284
link_object_hash[:links][:self] = self_link(source, relationship)

0 commit comments

Comments
 (0)