Style/lint tidy up models

This commit is contained in:
Brenda Wallace
2019-04-08 21:59:26 +12:00
parent e165c77d64
commit ccb69c5f7d
4 changed files with 12 additions and 13 deletions

View File

@@ -46,7 +46,6 @@ class Garden < ApplicationRecord
}.freeze
validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values,
message: "%<value>s is not a valid area unit" },
allow_nil: true,
allow_blank: true
after_validation :cleanup_area

View File

@@ -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: "%<value>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: "%<value>s is not a valid unit"
}
validate :crop_must_match_planting

View File

@@ -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: "%<value>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: "%<value>s is not a valid planting method"
}

View File

@@ -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" }
#