File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
lib/active_model_serializers/adapter/json_api Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,14 @@ def data_for_one(association)
4646 if association . belongs_to? &&
4747 parent_serializer . object . respond_to? ( association . reflection . foreign_key )
4848 id = parent_serializer . read_attribute_for_serialization ( association . reflection . foreign_key )
49- type = association . reflection . type . to_s
49+ if association . polymorphic?
50+ # We can't infer resource type for polymorphic relationships from the serializer.
51+ # We can ONLY know a polymorphic resource type by inspecting each resource.
52+ serializer = association . lazy_association . serializer
53+ type = serializer . json_key
54+ else
55+ type = association . reflection . type . to_s
56+ end
5057 ResourceIdentifier . for_type_with_id ( type , id , serializable_resource_options )
5158 else
5259 # TODO(BF): Process relationship without evaluating lazy_association
You can’t perform that action at this time.
0 commit comments