Skip to content

Commit a0f351d

Browse files
committed
only call base_class if record isn't nil
1 parent 86fa070 commit a0f351d

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+
klass = record.nil? ? record.class : record.class.base_class
7+
8+
owner[reflection.foreign_type] = klass
79
end
810
end
911
end

0 commit comments

Comments
 (0)