Introduction & time_zone_select with mapped TimeZone questio

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

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 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…:


Am I missing something ? Or is it just a quirk that mappings don’t mix
with time_zone_select ?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs