mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Handle correctly null associations
null belongs_to associations are now serialized as nil instead of raise an error during serialization.
This commit is contained in:
@@ -133,7 +133,7 @@ module ActiveModel
|
||||
self.class._associations.dup.each do |name, options|
|
||||
association = object.send(name)
|
||||
serializer_class = ActiveModel::Serializer.serializer_for(association)
|
||||
serializer = serializer_class.new(association)
|
||||
serializer = serializer_class.new(association) if serializer_class
|
||||
|
||||
if block_given?
|
||||
block.call(name, serializer, options[:options])
|
||||
|
||||
Reference in New Issue
Block a user