【问题标题】:Heroku: to_datetime does not take into account the rails' i18n.localeHeroku:to_datetime 没有考虑到 rails 的 i18n.locale
【发布时间】:2011-11-15 01:47:59
【问题描述】:

编辑:(要清楚明了)

我希望以下内容适用于 heroku:"11/13/2011".to_datetime,这意味着我需要日期为英文格式。谢谢


我在 application.rb 中设置了 i18n 语言环境

config.i18n.default_locale = :en
config.i18n.locale = :en

在 Heroku 控制台中:

I18n.locale
=> :en

所以看起来设置正确。

但是当我这样做时:

"11/13/2011".to_datetime
=> ArgumentError: invalid date

不!

你知道我在这里做错了什么吗?

谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 internationalization heroku string-to-datetime


    【解决方案1】:

    i18n 配置与我的问题无关。 只是一个 ruby​​ 版本的“问题”。

    我在本地环境中使用 ruby​​ 1.8.7,而 heroku 是 1.9.x。

    Rails 1.9 采用 EU 格式,1.8.7 不采用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 2015-01-14
      • 1970-01-01
      • 1970-01-01
      • 2014-11-10
      相关资源
      最近更新 更多