有这个articles.facets['date']['terms']
数组:
[{"term"=>13, "count"=>4}, {"term"=>12, "count"=>1}]
如果数组中有多个元素满足超过 10 年的要求,我只想打印一次此文本“超过 10 年”
<% articles.facets['yearsexperience']['terms'].each do |facet| %>
<% if facet['term'] > 10 %>
"More than 10 years"
<% end %>
<% end %>
我现在得到相同文本的 2 倍:
"More than 10 years"
"More than 10 years"