Skip to content

Commit df946c1

Browse files
author
Kyle d'Oliveira
committed
Should always try to do the lookup unless it is an integer
1 parent ded8795 commit df946c1

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

lib/polymorphic_integer_type/extensions.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ def belongs_to(name, options = {})
1717
end
1818

1919
define_method "#{foreign_type}=" do |klass|
20-
case klass
21-
when Integer then enum = klass
22-
when String then enum = mapping.key(klass)
23-
end
20+
enum = mapping.key(klass.to_s) || klass
2421
super(enum)
2522
end
2623

0 commit comments

Comments
 (0)