lib/blind_index/model.rb in blind_index-0.3.2 vs lib/blind_index/model.rb in blind_index-0.3.3

- old
+ new

@@ -47,10 +47,15 @@ define_method method_name do self.send("#{bidx_attribute}=", self.class.send(method_name, send(attribute))) end if callback - before_validation method_name, if: -> { changes.key?(attribute.to_s) } + if ActiveRecord::VERSION::STRING >= "5.1" + before_validation method_name, if: :"will_save_change_to_#{attribute}?" + else + before_validation method_name, if: -> { changes.key?(attribute.to_s) } + end + end # use include so user can override include InstanceMethods if blind_indexes.size == 1 end