How to validate inclusion of time zone?

Posted by LearningRoR on Stack Overflow See other posts from Stack Overflow or by LearningRoR
Published on 2012-09-09T21:24:55Z Indexed on 2012/09/09 21:38 UTC
Read the original article Hit count: 278

When I try:

validates_inclusion_of :time_zone, :in => TimeZone
validates_inclusion_of :time_zone, :in => Time.zone

This error appears:

"<class:User>": uninitialized constant User::TimeZone (NameError)

I'm trying to let users select any time zone of the world but since I'm based in the U.S.A. my select menu is this:

<%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones, {:prompt => "Select Your Time Zone *"}, {:id => "timezone"} %>

What's the correct way to do this?

Thank you.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby