Skip to content

Commit ac9adb0

Browse files
committed
Code was not adding foreign_type constraint
When we already had some constraints on the relation definition. Ex, below case did not work: has_many :constraints, as: :restricted_object, integer_type: true, :conditions => { :is_deleted => false } A workaround prior to this commit was to use the reverse mapping: has_many :constraints, as: :restricted_object, integer_type: true, :conditions => { :is_deleted => false, restricted_object_type: RESTRICTED_OBJECT_MAP_REVERSE[self.to_s] }
1 parent d9e5a33 commit ac9adb0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/polymorphic_integer_type/extensions.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def remove_type_and_establish_mapping(name, options)
4545

4646
options[:foreign_key] ||= "#{poly_type}_id"
4747
foreign_type = options.delete(:foreign_type) || "#{poly_type}_type"
48-
options[:conditions] ||= {foreign_type => klass_mapping.to_i}
48+
options[:conditions] ||= {}
49+
options[:conditions].merge!({foreign_type => klass_mapping.to_i})
4950
end
5051
end
5152

0 commit comments

Comments
 (0)