Module: ActiveRecord::Validations::UniquenessParanoiaValidator

Defined in:
lib/paranoia.rb

Instance Method Summary collapse

Instance Method Details

#build_relation(klass, *args) ⇒ Object


294
295
296
297
298
299
300
301
302
303
# File 'lib/paranoia.rb', line 294

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