How to add a validation that accepts only years above a certain value, Ruby on Rails -
currently have following:
validates :year, presence: true
however, need validate years later 1960. don't want have manually input of years , have reject years within range. also, years should not valid if greater present year.
numericality
validator should work here:
validates :year, numericality: { greater_than: 1960, less_than_or_equal_to: -> { date.current.year } }
Comments
Post a Comment