2011-01-07 1 views
1

これはactivesupport 2.3.5に移行したためだと思っていましたが、他に何かが起きたはずです。Rails time_ago_in_words悪い出力を生成する

モデルは、有効な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. 

は疑問に思います。モデルとビューのバージョン履歴を確認しましたが、最近変更されたものはありませんので、私は物事の設定面で何かを台無しにしているに違いないと思います。

答えて

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" 
+0

'gemfile'に' rails-i18n'という宝石があったことがありますか? –

関連する問題