Only check values.zero? if they are present

This commit is contained in:
Brenda Wallace committed 2017-01-14 20:09:09 +13:00
1 parent d07509f9e4
commit be07b5fd0e
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -48,7 +48,7 @@ class Garden < ActiveRecord::Base
after_validation :cleanup_area
def cleanup_area
self.area = nil if area.zero?
self.area = nil if area && area.zero?
self.area_unit = nil if area.blank?
end
+2 -2
View File
@@ -68,9 +68,9 @@ class Harvest < ActiveRecord::Base
end
def cleanup_quantities
self.quantity = nil if quantity.zero?
self.quantity = nil if quantity && quantity.zero?
self.unit = nil if quantity.blank?
self.weight_quantity = nil if weight_quantity.zero?
self.weight_quantity = nil if weight_quantity && weight_quantity.zero?
self.weight_unit = nil if weight_quantity.blank?
end