3
The Framework data validation parameters Ruby on Rails, use values with :
before and after the word.
validates :terms_of_service, acceptance: { accept: true, message: 'Mensagem de Validação' }
validates :city, presence: true
How they work and what kind of value they are?
What’s the difference in :
at the beginning and :
at the end of the word?
Note: The question is not intended to compare a String
"texto"
with a symbol for a String:texto
, and yes with the symbols:valor
andvalor:
.
Possible duplicate of Ruby - What’s the difference of using two dots or quotes in a string?
– Rafael Berro
@Rafaelberro, obviously the question is not duplicated, because it is not comparing the symbol of
string
with astring
but the symbol ofstring
with a key to the property of an object. as described in the answer below– Brumazzi DB