Closed rforte closed 12 years ago
because pen is a new pen with :name, :price, :color
set to nil
you must call .valid?
and .errors
on created pen!
oooh, totally misread the code where pen = Pen.new. Was looking at Pen.create :name => "Nice Pen", :price => 1.3, :color => "Red" and thought that was the 'pen' instance it was using. Hence the confusion. Thanks.
Not sure why in your example validation is failing on creating a Pen:
A pen object is being created with a name and a price so why is pen.errors showing name/price as validation errors?