mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Allow referencing sideloaded include by key. (#2136)
* If a `key` is set on the reflection use the `key` instead of `name`. This ensures that associations with a key set are still included.
This commit is contained in:
committed by
Benjamin Fleischer
parent
a5ab62fd18
commit
a89e78c655
@@ -140,7 +140,7 @@ module ActiveModel
|
||||
def include_data?(include_slice)
|
||||
include_data_setting = options[:include_data_setting]
|
||||
case include_data_setting
|
||||
when :if_sideloaded then include_slice.key?(name)
|
||||
when :if_sideloaded then include_slice.key?(options.fetch(:key, name))
|
||||
when true then true
|
||||
when false then false
|
||||
else fail ArgumentError, "Unknown include_data_setting '#{include_data_setting.inspect}'"
|
||||
|
||||
Reference in New Issue
Block a user