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

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -