title: Monkey patch Rails UniquenessValidator to support conditions
body: <p>In my Rails 3.2.11 application I need the uniqueness validator to support conditions, in order to ignore soft deleted records. On GitHub I found a pull request doing that (https://github.com/rails/rails/pull/5321) but this feature seems not to be part of the current Rails release. Now I created a patch for the UniquenessValidator class, which looks like this:</p>
  
  <pre><code>module UniquenessValidatorExtension
    def build_relation(klass, table, attribute, value)
      relation = super
      relation.merge!(options[:conditions]) if options[:conditions]
      relation
    end
  end
  
  ActiveRecord::Validations::UniquenessValidator.send :include, UniquenessValidatorExtension
  </code></pre>
  
  <p>To load this, I created an initializer. The problem is, that my method is never called. What do I do wrong?</p>
  
  <p>Here is the link to the current UniquenessValidator class: <a href="https://github.com/rails/rails/blob/0d73d6e7b6dd1900f105397460b777ef6c03d3b6/activerecord/lib/active_record/validations/uniqueness.rb" rel="nofollow">https://github.com/rails/rails/blob/0d73d6e7b6dd1900f105397460b777ef6c03d3b6/activerecord/lib/active_record/validations/uniqueness.rb</a></p>