Module: ActiveRecord::Validations::UniquenessParanoiaValidator

Included in:
UniquenessValidator
Defined in:
lib/paranoia.rb

Instance Method Summary collapse

Instance Method Details

#build_relation(klass, *args) ⇒ Object



341
342
343
344
345
346
347
348
349
350
# File 'lib/paranoia.rb', line 341

def build_relation(klass, *args)
  relation = super
  return relation unless klass.respond_to?(:paranoia_column)
  arel_paranoia_scope = klass.arel_table[klass.paranoia_column].eq(klass.paranoia_sentinel_value)
  if ActiveRecord::VERSION::STRING >= "5.0"
    relation.where(arel_paranoia_scope)
  else
    relation.and(arel_paranoia_scope)
  end
end