mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
This adds namespace lookup to serializer_for (#1968)
* This adds namespace lookup to serializer_for * address rubocop issue * address @bf4's feedback * add docs * update docs, add more tests * apparently rails master doesn't have before filter * try to address serializer cache issue between tests * update cache for serializer lookup to include namespace in the key, and fix the tests for explicit namespace * update docs, and use better cache key creation method * update docs [ci skip] * update docs [ci skip] * add to changelog [ci skip]
This commit is contained in:
committed by
GitHub
parent
b709cd41e6
commit
b29395b0ac
@@ -106,6 +106,10 @@ module ActiveModel
|
||||
#
|
||||
def build_association(parent_serializer, parent_serializer_options, include_slice = {})
|
||||
reflection_options = options.dup
|
||||
|
||||
# Pass the parent's namespace onto the child serializer
|
||||
reflection_options[:namespace] ||= parent_serializer_options[:namespace]
|
||||
|
||||
association_value = value(parent_serializer, include_slice)
|
||||
serializer_class = parent_serializer.class.serializer_for(association_value, reflection_options)
|
||||
reflection_options[:include_data] = include_data?(include_slice)
|
||||
|
||||
Reference in New Issue
Block a user