validates_inclusion_of no longer working the same in Rails 4.1?

前端 未结 3 1354
花落未央
花落未央 2020-12-31 20:29

The following code made sure that a time_zone chose is within the time zones in ActiveSupport::TimeZone.us_zones:

validates_inclusi         


        
3条回答
  •  余生分开走
    2020-12-31 21:20

    If you want to keep using validates_inclusion_of this works as well:

    validates_inclusion_of :time_zone, 
       :in => ActiveSupport::TimeZone.zones_map(&:name).keys, 
       :message => "is not a valid time zone"
    

提交回复
热议问题