mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Fix deserialization of nil relationships
failing test use try for when the assoc_data is possibly nil rubocop test/action_controller/json_api/deserialization_test.rb -a attempt to work on rails-master account for rails/master having instead of nil for assoc_data added changelog
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user