Commit c2a1dfac by Claessens Simon Committed by John Hawthorn

Use module.prepend instead of alias_method_chain

parent fc4cec00
......@@ -261,14 +261,16 @@ require 'paranoia/rspec' if defined? RSpec
module ActiveRecord
module Validations
class UniquenessValidator < ActiveModel::EachValidator
protected
def build_relation_with_paranoia(klass, table, attribute, value)
relation = build_relation_without_paranoia(klass, table, attribute, value)
module UniquenessParanoiaValidator
def build_relation(klass, table, attribute, value)
relation = super(klass, table, attribute, value)
return relation unless klass.respond_to?(:paranoia_column)
relation.and(klass.arel_table[klass.paranoia_column].eq(klass.paranoia_sentinel_value))
end
alias_method_chain :build_relation, :paranoia
end
class UniquenessValidator < ActiveModel::EachValidator
prepend UniquenessParanoiaValidator
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment