Reputation: 1555
If there any helper or method, that could provide me with select with timezone offset, which will generate only numbers in its view, e.g.(<option value="-6">-6</option>
)
I tried <%= time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones %>
, but this provide me with only string information, which wont work for me.
P.S. I'm about to switch to options_for_select
Upvotes: 0
Views: 443
Reputation: 1555
Here is how i did this
<%= collection_select :prefix, :suffix, ActiveSupport::TimeZone.us_zones, :utc_offset, :name,
{:selected => -21600}%>
Upvotes: 0
Reputation: 12818
There are no such built-in Rails helpers, but it's easy to implement with options_for_select
options_for_select(ActiveSupport::TimeZone.us_zones.map {|zone| zone.utc_offset / 3600}.uniq)
Upvotes: 1