T
T
tesusa2020-01-28 13:22:23
Ruby on Rails
tesusa, 2020-01-28 13:22:23

How to limit the time input field at the model level?

I don’t know how to solve the time input at the model / database level. The user can choose how much he can extend the time so that there is a step for entering time with an interval of 15 minutes 0,15,30 and so on. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zaporozhchenko Oleg, 2020-01-30
@c3gdlk

validates :time, :inclusion => { :in => (0..3600).step(15).to_a}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question