mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Support serialize polymorphic id
This commit is contained in:
@@ -245,7 +245,11 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def serialize_ids
|
||||
if object = associated_object
|
||||
object = associated_object
|
||||
|
||||
if object && polymorphic?
|
||||
{ polymoprhic_key => object.read_attribute_for_serialization(:id) }
|
||||
elsif object
|
||||
object.read_attribute_for_serialization(:id)
|
||||
else
|
||||
nil
|
||||
|
||||
Reference in New Issue
Block a user