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:
NullVoxPopuli
2016-04-01 08:39:23 -04:00
parent 96c5516d21
commit 5be33afbfb
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