small medium large xlarge

 

Task-B-ValidationAndUnitTesting

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

Page History
  • V6: Sam Ruby [about 5 years ago]
  • V5: Sam Ruby [about 5 years ago]
  • V4: Andrew de Andrade [over 5 years ago]
  • V3: Andrew de Andrade [over 5 years ago]
  • V2: Andrew de Andrade [over 5 years ago]
  • V1: Andrew de Andrade [over 5 years ago]