gpt4 book ai didi

ruby-on-rails - 仅使用 Rails pluralize helper 将强样式应用于数字

转载 作者:数据小太阳 更新时间:2023-10-29 08:15:12 25 4
gpt4 key购买 nike

我有这个:

<%= link_to biscuits_path do %>
<strong> <%= pluralize @biscuit.count, t('biscuits') %> </strong>
<%= end %>

结果是这样的链接:

<a href="/en/biscuits"> <strong> 2 Biscuits </strong></a>

我想要一个只有数字强的链接,比如:

<a href="/en/biscuits"> <strong> 2 </strong> Biscuits </a>

我该怎么做?

最佳答案

使用起来更简单明了StringActiveSupport 复数核心扩展:

<%= link_to biscuits_path do %>
<strong><%= @biscuit.size %></strong> <%= "biscuit".pluralize(@biscuit.size)%>
<% end %>

此外,您不需要 <%= end %> . <% end %>很好。

关于ruby-on-rails - 仅使用 Rails pluralize helper 将强样式应用于数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11171252/

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