# Noob validation question for time\_zone

**URL:** <https://www.ruby-forum.com/t/noob-validation-question-for-time-zone/170110>\
**Category:** Rails\
**Created:** [June 12, 2009, 1:23pm UTC](https://www.ruby-forum.com/t/noob-validation-question-for-time-zone/170110 "2009-06-12T13:23:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [June 12, 2009, 1:23pm UTC](https://www.ruby-forum.com/t/noob-validation-question-for-time-zone/170110/1 "2009-06-12T13:23:13Z")

</div>

Despite much googling and book checking, I can’t for the life of me  
figure out how to check if the time\_zone object is nil. The situation  
is that I built a fun little delayed email delivery app –  
[http://mailthislater.com](http://mailthislater.com)  
if you’re interested – and want to ensure that the user selects his  
time zone. I can validate, throw errors on, and rescue all the other  
form fields. I tried checking in the before\_filter that creates the  
time zone object, in the create method, but no dice. I think I’m just  
not understanding some of the basics - so I’m sorry if this isn’t even  
a meaningful question. Would it help if I posted controller code?  
Thanks.

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [June 12, 2009, 2:13pm UTC](https://www.ruby-forum.com/t/noob-validation-question-for-time-zone/170110/2 "2009-06-12T14:13:04Z")

</div>

You can do validates\_presence\_of :time\_zone in the relevant model to  
ensure that the field is not left blank.

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [June 12, 2009, 2:24pm UTC](https://www.ruby-forum.com/t/noob-validation-question-for-time-zone/170110/3 "2009-06-12T14:24:14Z")

</div>

2009/6/12 Jon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Thanks.  
> validates\_presence\_of will check that a value has been entered for a  
> field so may do what you are looking for.

Colin

---

<div class="post-metadata">

**Author:** ![jon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@jon](https://www.ruby-forum.com/u/jon)\
**Post date:** [June 12, 2009, 4:32pm UTC](https://www.ruby-forum.com/t/noob-validation-question-for-time-zone/170110/4 "2009-06-12T16:32:16Z")

</div>

Thanks Ryan, Colin – I should have gone with my first instinct to  
validate in the model. Works now!
