Issue validating user time zone for Rails app on Heroku

删除回忆录丶 提交于 2020-01-05 02:43:08

问题


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.

来源:https://stackoverflow.com/questions/18325997/issue-validating-user-time-zone-for-rails-app-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!