Nick Brutyn wrote:> hey, i have a record in the database gtm_zone with value
''Europe/London''
>
> i want to have a select box with all the zones and the corrected selected
> @firm.gmt_zone = Europe/London
>
> TimeZone from ruby (trying to expand with TZinfo)
> dont want to select Europe/London, and not sorted
>
> <select id="firm_gmt_zone" name="firm[gmt_zone]">
> <%= time_zone_options_for_select(selected = @firm.gmt_zone,
> priority_time_zones = nil, model = TZInfo::Timezone) %><br />
> </select>
>
>
> the selectlist from TZInfo
> this list is sorted, but the value isnt selected
>
> <%= time_zone_select ''user'',
''time_zone'', TZInfo::Timezone.all.sort,
> :model => TZInfo::Timezone, :selected => @firm.gmt_zone %>
The first argument of time_zone_select is the name of the object. The
second is the name of the attribute containing the timezone name.
:selected isn''t needed. You probably want use the following:
<%= time_zone_select ''firm'', ''gmt_zone'',
TZInfo::Timezone.all.sort,
:model => TZInfo::Timezone %>
Phil
--
Philip Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby