Activity 1

The validation option :length checks the length of a model attribute. Add validation to the product model to check that the title is at least ten characters long.

Hint: you can find an example in the API documentation.

Discuss

Activity 2

Change the error message associated with one of your validations.

Hint: the generic validates method simply calls a more specific validate_xxx method to handle the request, passing along any arguments that it receives. You can see examples of passing error messages in the “API documentation”http://api.rubyonrails.org/classes/ActiveModel/Validations/HelperMethods.html#method-i-validates_length_of for some of the more specific methods.

Discuss