Issue validating user time zone for Rails app on H

2019-07-19 11:16发布

I'm following Ryan Bates' tutorial on adding time zones to a rails app.

http://railscasts.com/episodes/106-time-zones-revised

(It's a good tutorial, by the way)

Anyway, Ryan says it's a good idea to validate the submitted time zone with the ones that Rails knows about. He put this rule into the users' model:

validates_inclusion_of :time_zone, in: ActiveSupport::TimeZone.zones_map(&:name)

That works fine in development. However, when I run the app on Heroku, it does not like the timezone "Melbourne" (and many others - I'm mainly testing AU time zones).

On Heroku, with that rule in the user model, it will not accept a time zone of "Melbourne".

Why would that be? The time_zone_select view helper returns "Melbourne" - so rails must be aware of it.

0条回答
登录 后发表回答