O'Reilly logo

The Rails Way by Obie Fernandez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. ActiveRecord Validations

 

Computers are like Old Testament gods; lots of rules and no mercy.

 
 --Joseph Campbell

The Validations API in ActiveRecord allows you to declaratively define valid states for your model objects. The validation methods hook into the life cycle of an ActiveRecord model object and are able to inspect the object to determine whether certain attributes are set, have values in a given range, or pass any other logical hurdles that you specify.

In this chapter, we’ll describe the validation methods available and how to use them effectively. We’ll explore how those validation methods interact with your model’s attributes and how the built-in error-messaging system messages can be used effectively in your application’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required