The following code made sure that a time_zone
chose is within the time zones in ActiveSupport::TimeZone.us_zones
:
validates_inclusion_of :time_zone, in: ActiveSupport::TimeZone.zones_map(&:name)
Worked great in Rails 4.0. Just upgraded to Rails 4.1 and I'm getting this error on my index page (so just simply viewing the models):
An object with the method #include? or a proc, lambda or symbol is required, and must be supplied as the :in (or :within) option of the configuration hash
I'm guessing from that, ActiveSupport::TimeZone.zones_map(&:name)
is no longer a valid value for the in
property?
try adding .keys
?
validates :time_zone,
inclusion: {
in: ActiveSupport::TimeZone.zones_map.keys
}