2

这是我的en.yml 语言环境

en:
  datetime:
    distance_in_words:
      less_than_x_seconds:
        one: "1 sec"
        other: "%{count} secs"
      x_seconds:
        one: "1 sec"
        other: "%{count} secs"
      less_than_x_minutes:
        one: "1 min"
        other: "%{count} mins"
      x_minutes:
        one: "1 min"
        other: "%{count} mins"
      about_x_hours:
        one: "1 hour"
        other: "%{count} hours"
      x_days:
        one: "1 day"
        other: "%{count} days"
      about_x_months:
        one: "1 month"
        other: "%{count} months"
      x_months:
        one: "1 month"
        other: "%{count} months"
      about_x_years:
        one: "1 year"
        other: "%{count} years"
      over_x_years:
        one: "1 year"
        other: "%{count} years"
      almost_x_years:
        one: "1 year"
        other: "%{count} years"

每当我发布我使用的东西时

<%= link_to time_ago_in_words(post.created_at), post_path(post) %>

显示自帖子创建以来的时间,而不是显示1 sec2 secs等...它显示1 min,并继续显示分钟

4

1 回答 1

4

您需要传递truetime_ago_in_wordsinclude_seconds参数:

time_ago_in_words(post.created_at, true)

请参阅 的文档distance_of_time_in_wordstime_ago_in_words了解更多详细信息。

于 2012-09-10T07:36:34.000 回答