如何使用简单形式过滤:time_zone?
-
20-12-2019 - |
题
= simple_form_for user,
= f.input :time_zone
.
返回GMT-11:00之间的所有时区的Dropbox到GMT + 13:00,并且它相应的时区名称。
如何仅在GMT + 02:00之间过滤/显示到GMT-05:00在Dropbox中,并将其与(GMT-HH:MM) ZONE_NAME
保持相同的结构?
解决方案
我创立的唯一方法是添加帮助:
module TimezonesHelper
def timezones_filtered
[['(GMT-05:00) Lima', 'Lima' ],
['(GMT-04:00) La Paz', 'La Paz' ],
['(GMT-03:00) Brasilia', 'Brasilia' ],
['(GMT+00:00) UTC', 'UTC' ]]
end
end
.
并以这种方式使用:
= simple_form_for user
= f.input :time_zone, selected: 'Brasilia', collection: timezones_filtered
. 不隶属于 StackOverflow