Adnan
Adnan

Reputation: 26350

date in future for Rails

I am trying to make a validation that will validate that the entered date is in future and that the selected date is in the next 7 days.

In order to validate if the date is in future I use;

valid_until.future? 

and this one works fine, but to make a validation to check if the date selected is withing 7 days from now?

Upvotes: 2

Views: 7473

Answers (1)

alex.zherdev
alex.zherdev

Reputation: 24164

valid_until.future? && valid_until < 7.days.since(Time.now).to_date

Upvotes: 12

Related Questions