Last active
October 7, 2015 02:49
-
-
Save simkessy/a98a86ab45ff52edc8b9 to your computer and use it in GitHub Desktop.
Trying to have Rails Admin timezone match with form timezone select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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