Hi
I have the following:
***** CODE *****
class DailyStat < ActiveRecord::Base
validates_presence_of :player_name, :team, :pos, :gp
validates_numericality_of :pts, :plus_minus, :gt, :en, :only_integer
=> true
validates_numericality_of :save_percent
validates_uniqueness_of :player_name
protected
def valdidate
errors.add( :pts, “Should be a positive integer.” ) if pts.nil? ||
pts <= 0
errors.add( :gt, “Should be a positive integer.” ) if gt.nil? || gt
<= 0
errors.add( :en, “Should be a positive integer.” ) if en.nil? || en
<= 0
end
end
*** END CODE ***
In my form I am able to enter negative numbers in the field and they
dont throw errors and are successfully stored into the database.
Thanks.