Adnan
Adnan

Reputation: 26350

check if a date is older that the current time in Rails

I am doing a validations in my model to check if a date is older than today (meaning a date can only be in future from the current time)

I was about to write down a block of code, but was wondering is there a build in function for this.

The date is passed from a view using:

<%= date_select ('load', :valid_until, :order => [:day, :month, :year]) %>

All ideas are appreciated.

Upvotes: 1

Views: 1017

Answers (1)

JRL
JRL

Reputation: 77995

Yep, there's indeed a built-in date.future? method.

Upvotes: 5

Related Questions