# About validate

**URL:** <https://www.ruby-forum.com/t/about-validate/160325>\
**Category:** Rails\
**Created:** [February 14, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/about-validate/160325 "2009-02-14T15:26:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike75](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac8455/32.png) [@Mike75](https://www.ruby-forum.com/u/Mike75)\
**Post date:** [February 14, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/about-validate/160325/1 "2009-02-14T15:26:44Z")

</div>

hello…

I am new to Ruby on Rails… (2.2)  
I am currently following steps from the book “agile web delopment with  
Rails” building depot application.

It says I need to edit “app/models/product.rb” file and add the  
following lines to check the price to be at least a cent… that’s 0.01

* * *

## def price\_must\_be\_at\_least\_a\_cent errors.add(:price, ‘should be at least 0.01’ ) if price.nil? || price \< 0.01 end

after this, I typed 0.1 and 0.10, and get the error… saying “should  
be at least 0.01”…  
if I type 1, or 0.01… I don’t get the error.

am I the only one with this problem? if so, i’d like to know what I  
need to do to fix the problem.

thanks

---

<div class="post-metadata">

**Author:** ![Mike75](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac8455/32.png) [@Mike75](https://www.ruby-forum.com/u/Mike75)\
**Post date:** [February 14, 2009, 3:56pm UTC](https://www.ruby-forum.com/t/about-validate/160325/2 "2009-02-14T15:56:38Z")

</div>

i just tried it for myself. it’s working correctly. so i advice to put  
a debugger at the beginning of your action and look what you are  
getting for price and where the error occurrs (whether it’s inside  
that method or even before).

---

<div class="post-metadata">

**Author:** ![Mike75](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac8455/32.png) [@Mike75](https://www.ruby-forum.com/u/Mike75)\
**Post date:** [February 16, 2009, 1:31am UTC](https://www.ruby-forum.com/t/about-validate/160325/3 "2009-02-16T01:31:51Z")

</div>

thank you for trying it out for me… and for the advice too…

I ran over the steps again… and it works fine now…  
I found out why too…  
when I added a new column “price” to the table… I forgot to write  
its :precesion and :scale …  
I hope I don’t make mistakes like that no more…

thank u MaD
