diff --git a/app/models/garden.rb b/app/models/garden.rb index 7987c4dc2..fcbb32ea6 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -46,7 +46,6 @@ class Garden < ApplicationRecord }.freeze validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values, message: "%s is not a valid area unit" }, - allow_nil: true, allow_blank: true after_validation :cleanup_area diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 94b71d7b4..c3ea95b66 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -57,11 +57,11 @@ class Harvest < ApplicationRecord validates :quantity, allow_nil: true, numericality: { only_integer: false, greater_than_or_equal_to: 0 } - validates :unit, allow_nil: true, allow_blank: true, inclusion: { + validates :unit, allow_blank: true, inclusion: { in: UNITS_VALUES.values, message: "%s is not a valid unit" } validates :weight_quantity, allow_nil: true, numericality: { only_integer: false } - validates :weight_unit, allow_nil: true, allow_blank: true, inclusion: { + validates :weight_unit, allow_blank: true, inclusion: { in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" } validate :crop_must_match_planting diff --git a/app/models/planting.rb b/app/models/planting.rb index 08a78fdd8..9c4a59be5 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -56,10 +56,10 @@ class Planting < ApplicationRecord validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :sunniness, allow_nil: true, allow_blank: true, inclusion: { + validates :sunniness, allow_blank: true, inclusion: { in: SUNNINESS_VALUES, message: "%s is not a valid sunniness value" } - validates :planted_from, allow_nil: true, allow_blank: true, inclusion: { + validates :planted_from, allow_blank: true, inclusion: { in: PLANTED_FROM_VALUES, message: "%s is not a valid planting method" } diff --git a/app/models/seed.rb b/app/models/seed.rb index 253718039..7c49c9201 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -29,17 +29,17 @@ class Seed < ApplicationRecord numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :days_until_maturity_max, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :tradable_to, allow_nil: false, allow_blank: false, - inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\ + validates :tradable_to, allow_blank: false, + inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\ "locally, nationally, or internationally" } - validates :organic, allow_nil: false, allow_blank: false, - inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\ + validates :organic, allow_blank: false, + inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\ "are organic or not, or that you don't know" } - validates :gmo, allow_nil: false, allow_blank: false, - inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\ + validates :gmo, allow_blank: false, + inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\ "genetically modified or not, or that you don't know" } - validates :heirloom, allow_nil: false, allow_blank: false, - inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\ + validates :heirloom, allow_blank: false, + inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\ "are heirloom, hybrid, or unknown" } #