lib/mongoid/validatable/uniqueness.rb
# Get the name of the field and the value to validate. This is for the
# case when we validate an association via the association name and not the key,
# we need to send the key name and value to the db, not the association
# object.
#
# @api private
#
# @example Get the name and key to validate.
#   validator.to_validate(doc, :parent, Parent.new)
#
# @param [ Document ] document The doc getting validated.
# @param [ Symbol ] attribute The attribute getting validated.
# @param [ Object ] value The value of the attribute.
#
# @return [ Array<Object, Object> ] The field and value.
Get the name of the field and the value to validate. This is for the
case when we validate an association via the association name and not the key,
we need to send the key name and value to the db, not the association
object.
Get the name of the field and the value to validate . This is for the case when we validate an association via the association name and not the key we need to send the key name and value to the db not the association object .
def to_validate(document, attribute, value)
        association = document.relations[attribute.to_s]
        if association && association.stores_foreign_key?
          [ association.foreign_key, value && value._id ]
        else
          [ attribute, value ]
        end
      end
def to_validate ( document , attribute , value ) association = document . relations [ attribute . to_s ] if association && association . stores_foreign_key? [ association . foreign_key , value && value . _id ] else [ attribute , value ] end end
Get the name of the field and the value to validate.
Get the name of the field and the value to validate .
The field and value.
The field and value .
 Array<Object, Object> 
document
<not_specific>
attribute
<not_specific>
value
<not_specific>
<not_specific>
value The value of the attribute.
value The value of the attribute .
api
None
example
Get the name and key to validate. validator.to_validate(doc, :parent, Parent.new)
Get the name and key to validate . validator . to_validate ( doc : parent Parent . new )