We are using the following to check if stock_qty (an integer or a float. Could be zero but not nil) is greater or equal to zero:
validates_numericality_of :stock_qty, :greater_than_or_equal_to => 0
validates_numericality_of :stock_qty, :less_than_or_equal_to => :in_qty, :if => Proc.new { |part| !part.in_qty.nil? }
:in_qty is a column in part model. This validation should allow positive or 0 for :stock_qty. The problem is that the rspec failed if :stock_qty is assigned zero. I noticed that :less_than_or_equal_to only allowed less_than and did not allow equal_to. Is there a way to validate the >= or <= in rails 3.1? Or what may go wrong with our validation code above. Thanks so much.