time_zone_select
time_zone_select(object, method, priority_zones = nil, options = {}, html_options = {})
public
Return select and option tags for the given object and method, using #time_zone_options_for_select to generate the list of option tags.
In addition to the :include_blank option documented above, this method also supports a :model option, which defaults to TimeZone. This may be used by users to specify a different time zone model object. (See #time_zone_options_for_select for more information.) Finally, this method supports a :default option, which selects a default TimeZone if the object’s time zone is nil.
Examples:
time_zone_select( "user", "time_zone", nil, :include_blank => true) time_zone_select( "user", "time_zone", nil, :default => "Pacific Time (US & Canada)" ) time_zone_select( "user", 'time_zone', TimeZone.us_zones, :default => "Pacific Time (US & Canada)") time_zone_select( "user", "time_zone", TZInfo::Timezone.all.sort, :model => TZInfo::Timezone)
uninitialized constant ActionView::Base::CompiledTemplates::TimeZone
If you get this error, you need to use ActiveSupport::TimeZone.us_zones instead of TimeZone.us_zones.
Example:
<%= form.time_zone_select(:time_zone, ActiveSupport::TimeZone.us_zones) %>