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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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