irb(main):001:0> require 'date'
=> true

irb(main):002:0> d1 = Date.new(2009, 4, 1)
=> #<Date: 2009-04-01 (4909845/2,0,2299161)>

irb(main):003:0> d2 = Date.new(2009, 5, 1)
=> #<Date: 2009-05-01 (4909905/2,0,2299161)>

irb(main):004:0> d3 = Date.new(2009, 6, 1)
=> #<Date: 2009-06-01 (4909967/2,0,2299161)>

irb(main):005:0> d2.between? d1, d3
=> true


On Oct 16, 12:24 pm, "[email protected]"
<[email protected]> wrote:
> Create your own validation method like this:
>
> http://guides.rubyonrails.org/activerecord_validations_callbacks.html...
>
> > What is the best way to validate date periods? I have a model which has
> > two date attributes, and the user is not able to create a new record if
> > date1 is greater than date2. I tried using validates_numericality_of but
> > it doesn't work with dates.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to