mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Add test cases for nil polymorphic associations
This commit is contained in:
@@ -131,10 +131,12 @@ module ActiveModel
|
||||
|
||||
|
||||
def serialize_ids(object, scope)
|
||||
if polymorphic?
|
||||
if polymorphic? && object
|
||||
{
|
||||
polymorphic_key(object) => object.read_attribute_for_serialization(:id),
|
||||
}
|
||||
elsif polymorphic? && !object
|
||||
{ }
|
||||
elsif object
|
||||
{ key => object.read_attribute_for_serialization(:id) }
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user