1

これは、activesupport 2.3.5 に移行したことが原因ではないかと考えていましたが、別のことが起こったに違いないと考えています。

モデルには有効な rfc822 スタイルの日付があります:

>> s.lastVisitDate
=> "Thu, 06 Jan 2011 22:24:10 -0800"

しかし、私の見解では:

<%=h time_ago_in_words(@site.lastVisitDate) -%>

renders: *about {{count}} hours ago* 
instead of: *about 2 hours ago* which was working just fine earlier.

他の誰かがこの動作を見たことがあるかどうか疑問に思います。モデルとビューのバージョン履歴を確認しましたが、最近何も変更されていないため、構成側で何かを台無しにしたに違いないと思います。

4

1 に答える 1

0

ロケール ファイルに適切な値が含まれていないことがわかりました。

したがって、私の場合、次を /config/locales/en.yml に追加しました

これが以前に機能していた理由や、特定の宝石または構成の変更がこの問題を引き起こした理由はわかりませんが、ここで適切な定義を行うことでアクションパックを満足させることができます.

# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
  datetime:
    distance_in_words:
      half_a_minute: "half a minute"
      less_than_x_seconds:
        one:   "less than 1 second"
        other: "less than %{count} seconds"
      x_seconds:
        one:   "1 second"
        other: "%{count} seconds"
      less_than_x_minutes:
        one:   "less than a minute"
        other: "less than %{count} minutes"
      x_minutes:
        one:   "1 minute"
        other: "%{count} minutes"
      about_x_hours:
        one:   "about 1 hour"
        other: "about %{count} hours"
      x_days:
        one:   "1 day"
        other: "%{count} days"
      about_x_months:
        one:   "about 1 month"
        other: "about %{count} months"
      x_months:
        one:   "1 month"
        other: "%{count} months"
      about_x_years:
        one:   "about 1 year"
        other: "about %{count} years"
      over_x_years:
        one:   "over 1 year"
        other: "over %{count} years"
      almost_x_years:
        one:   "almost 1 year"
        other: "almost %{count} years"
    prompts:
      year:   "Year"
      month:  "Month"
      day:    "Day"
      hour:   "Hour"
      minute: "Minute"
      second: "Seconds"
于 2011-01-07T09:29:58.003 に答える