Merge pull request #1651 from NullVoxPopuli/deserialization-error-with-no-attributes

Fix for Deserialization erroring when a relationship is null in the json api document.
This commit is contained in:
Benjamin Fleischer
2016-04-03 14:32:24 -05:00
3 changed files with 44 additions and 1 deletions

View File

@@ -188,7 +188,9 @@ module ActiveModelSerializers
end
polymorphic = (options[:polymorphic] || []).include?(assoc_name.to_sym)
hash["#{prefix_key}_type".to_sym] = assoc_data[:type] if polymorphic
if polymorphic
hash["#{prefix_key}_type".to_sym] = assoc_data.present? ? assoc_data[:type] : nil
end
hash
end