Skip to content

Instantly share code, notes, and snippets.

@simkessy
Last active October 7, 2015 02:49
Show Gist options
  • Save simkessy/a98a86ab45ff52edc8b9 to your computer and use it in GitHub Desktop.
Save simkessy/a98a86ab45ff52edc8b9 to your computer and use it in GitHub Desktop.
Trying to have Rails Admin timezone match with form timezone select
validates_inclusion_of :time_zone, in: ActiveSupport::TimeZone.us_zones.map { |z| z.name },
message: "is not a valid time zone",
allow_blank: true
# This allows me to display the time_zone as a dropdown in rails admin instead of a text box
TIMEZONES = ActiveSupport::TimeZone.us_zones.map { |z| z.name }
def time_zone_enum
TIMEZONES.each_with_index.to_a
end
<%= f.collection_select :time_zone, ActiveSupport::TimeZone.us_zones.map { |z| z.name }, value, name %>
# I don't know how to get the value to be an index of the map operation and to display the name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment