ruby on rails time_ago_in_words几秒钟前没有显示

时间:2021-09-09 21:31:07

Here is my en.yml locale

这是我的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"

Whenever i post something i use

每当我发布我使用的东西

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

to display the time ago since the post was created but instead of showing 1 sec, 2 secs etc... it displays 1 min, and continues with minutes

显示自帖子创建以来的时间,但不是显示1秒,2秒等...它显示1分钟,并继续分钟

1 个解决方案

#1


3  

You need to pass true to time_ago_in_words's include_seconds parameter:

您需要将true传递给time_ago_in_words的include_seconds参数:

time_ago_in_words(post.created_at, true)

See the documentation for distance_of_time_in_words, which is used by time_ago_in_words for more detail.

请参阅distance_of_time_in_words的文档,time_ago_in_words使用该文档以获取更多详细信息。

#1


3  

You need to pass true to time_ago_in_words's include_seconds parameter:

您需要将true传递给time_ago_in_words的include_seconds参数:

time_ago_in_words(post.created_at, true)

See the documentation for distance_of_time_in_words, which is used by time_ago_in_words for more detail.

请参阅distance_of_time_in_words的文档,time_ago_in_words使用该文档以获取更多详细信息。