method
scope_relation
v4.2.9 -
Show latest stable
- Class:
ActiveRecord::Validations::UniquenessValidator
scope_relation(record, table, relation)protected
No documentation available.
# File activerecord/lib/active_record/validations/uniqueness.rb, line 86
def scope_relation(record, table, relation)
Array(options[:scope]).each do |scope_item|
if reflection = record.class._reflect_on_association(scope_item)
scope_value = record.send(reflection.foreign_key)
scope_item = reflection.foreign_key
else
scope_value = record._read_attribute(scope_item)
end
relation = relation.and(table[scope_item].eq(scope_value))
end
relation
end