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:
Christian
2017-05-18 13:59:14 -07:00
committed by Benjamin Fleischer
parent a5ab62fd18
commit a89e78c655
3 changed files with 34 additions and 3 deletions

View File

@@ -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}'"