# How do you validate the availability for a "block of time"?

**URL:** <https://www.ruby-forum.com/t/how-do-you-validate-the-availability-for-a-block-of-time/149993>\
**Category:** Rails\
**Created:** [October 2, 2008, 2:09am UTC](https://www.ruby-forum.com/t/how-do-you-validate-the-availability-for-a-block-of-time/149993 "2008-10-02T02:09:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [October 2, 2008, 2:09am UTC](https://www.ruby-forum.com/t/how-do-you-validate-the-availability-for-a-block-of-time/149993/1 "2008-10-02T02:09:21Z")

</div>

I’m building an “appointment time” application, where the user selects  
an appointment time through a datetime\_select field.

I’m trying to validate that the appointment time the user selects is  
available.

The appointment times are for 30 minutes each, so a user should not be  
able to create a new appointment time within 30 minutes of an existing  
appointment.

Do you know how to validate that in the Appintment model?

(e.g.

def validates\_available\_appointment\_time\_slot  
…  
end

)

Any ideas?

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [October 2, 2008, 2:34am UTC](https://www.ruby-forum.com/t/how-do-you-validate-the-availability-for-a-block-of-time/149993/2 "2008-10-02T02:34:30Z")

</div>

Bob -

On 1-Oct-08, at 8:09 PM, Bob S. wrote:

> Any ideas?  
> runt is great for managing date blocks

[http://runt.rubyforge.org/](http://runt.rubyforge.org/)

J
