Skip to content

Commit 4c1ff5f

Browse files
committed
try doing nothing if record nil
1 parent afeac5a commit 4c1ff5f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module Associations
33
class BelongsToPolymorphicAssociation < BelongsToAssociation
44
private def replace_keys(record)
55
super
6-
owner[reflection.foreign_type] = record&.class&.base_class
6+
unless record.nil?
7+
owner[reflection.foreign_type] = record.class.base_class
8+
end
79
end
810
end
911
end

0 commit comments

Comments
 (0)