Module: ActiveRecord::Validations::UniquenessParanoiaValidator

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

Instance Method Summary collapse

Instance Method Details

#build_relation(klass, table, attribute, value) ⇒ Object



266
267
268
269
270
271
272
273
274
275
# File 'lib/paranoia.rb', line 266

def build_relation(klass, table, attribute, value)
  relation = super(klass, table, attribute, value)
  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