# Introduction & time\_zone\_select with mapped TimeZone questio

**URL:** <https://www.ruby-forum.com/t/introduction-time-zone-select-with-mapped-timezone-questio/53244>\
**Category:** Rails\
**Created:** [January 30, 2006, 11:38am UTC](https://www.ruby-forum.com/t/introduction-time-zone-select-with-mapped-timezone-questio/53244 "2006-01-30T11:38:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wybo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/cc9497/32.png) [@wybo](https://www.ruby-forum.com/u/wybo)\
**Post date:** [January 30, 2006, 11:38am UTC](https://www.ruby-forum.com/t/introduction-time-zone-select-with-mapped-timezone-questio/53244/1 "2006-01-30T11:38:56Z")

</div>

I’m new to this list, I’m a student in History, Computerscience and a  
bit of Philosophy from the Netherlands… I have started using rails a  
few weeks ago, I did read the Agile Webdevelopment with Rails book, and  
I generally started to love Rails for it’s sheer beauty and intelligent  
structure…

However I came across something that puzzles me quite a bit. It’s how to  
add a time\_zone\_select form field using a composed\_of class with mapped  
utc\_offset and name fields…

In my form I have:

\<%= time\_zone\_select(‘user’,‘time\_zone’) %\>

In my user-class I have:

composed\_of :time\_zone, :class\_name =\> ‘TimeZone’, :mapping =\>  
[%w(time\_zone\_name name) %w(time\_zone\_utc\_offset utc\_offset)]

And I get this error:

undefined local variable or method `utc\_offset’ for User:Class

I am using the stable version of Rails and User is part of the  
user\_engine, but that should make no difference as I did overload the  
user-class (and other fields are working)…

I tried a few alternatives to the time\_zone\_select vars (it’s not  
documented in the api exactly what arguments are requested…) like:  
\<%= time\_zone\_select(‘user.time\_zone’,‘time\_zone\_name’) %\>  
\<%= time\_zone\_select(‘user.time\_zone’,‘time\_zone\_utc\_offset’) %\>

But none of these work… It seems that it doesn’t get the mapping.

While I think it is quite a common problem. I mean no one wants the  
ugly situation of a user.name field holding the name of a timezone,  
while almost all timezones are set using forms…

I also had a look at the use of the TZInfo library, but it does seem  
likely that rails will one day support daylight savings times ?..and  
in that case it is wise to stick with rails…:  
[http://lunchroom.lunchboxsoftware.com/pages/tzinfo\_rails](http://lunchroom.lunchboxsoftware.com/pages/tzinfo_rails)

Wybo

---

<div class="post-metadata">

**Author:** ![wybo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/cc9497/32.png) [@wybo](https://www.ruby-forum.com/u/wybo)\
**Post date:** [January 31, 2006, 1:28am UTC](https://www.ruby-forum.com/t/introduction-time-zone-select-with-mapped-timezone-questio/53244/2 "2006-01-31T01:28:08Z")

</div>

Am I missing something ? Or is it just a quirk that mappings don’t mix  
with time\_zone\_select ?

Wybo
