Validating Objects Before Saving In Rails

Pledge Davis
2 min readJun 20, 2021

When creating objects in Rails you always want to make sure that the information you’re saving to the database is valid. For example, if you were to have a Dog model and its attributes are a name, breed, color, and age. And for it to qualify as a Dog, it will have to have those attributes upon creation or it should not be saved into our database as a Dog object. Luckily Rails gives us validation’s to handle verifying created objects that need to be stored in our database. To configure your model with validations you will have to add the validates method which allows you to add your…

--

--