^
symbol has multiple uses in ROR
.
1- As a bitwise XOR Operator
For each bit in the binary representation of the operands, a bitwise XOR will get a 1 bit if one of the corresponding bits in the operands is 1, but not both, otherwise, the XOR will get a 0 bit. Here's an example:
5 = 101
6 = 110
5 ^ 6 = 011 = 3
2- In Rails validation error message
When you want to override the error message without the attribute name, simply prepend the message with ^
like
validates_numericality_of :identity_id, :message => "^Person field definition id must be an integer"
you get
Person field definition id must be an integer
instead of
Identity Id Person field definition id must be an integer
Top comments (0)