gpt4 book ai didi

ruby-on-rails - ruby on rails time_ago_in_words 秒前不显示

转载 作者:行者123 更新时间:2023-12-04 18:12:28 28 4
gpt4 key购买 nike

这是我的 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 秒 , 2 秒 等等...它显示 1 分钟 , 并继续 分钟

最佳答案

您需要通过truetime_ago_in_wordsinclude_seconds范围:

time_ago_in_words(post.created_at, true)

documentation for distance_of_time_in_words ,由 time_ago_in_words 使用了解更多详情。

关于ruby-on-rails - ruby on rails time_ago_in_words 秒前不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12347053/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com