Undefined local variable or method `errors' for Customer:Cla

If I add the following line to my customer model:
errors.add(:shipping_address_postcode, “has invalid format”) unless
:shipping_address_postcode =~ /[0-9]*/

I get an error when trying to save a record:

undefined local variable or method `errors’ for Customer:Class

I got this example from the Agile book. Anyone know what I’ve missed?

Thanks,
Dan

Dan H. wrote:

If I add the following line to my customer model:
errors.add(:shipping_address_postcode, “has invalid format”) unless
:shipping_address_postcode =~ /[0-9]*/

I get an error when trying to save a record:

undefined local variable or method `errors’ for Customer:Class

It’s OK, I figured it out. I needed to put this line in a “def
validate” section.

Dan