Rails自动增量打印

独自的

我有以下代码,这些代码在单独的列中打印项目列表。

- if @product.type_id == 2
      %th.order_invoice_cell.each.count
        #{l(:item)}
      - @product.products.each do |p|
        %th.order_invoice_cell
          #{l(:item)}

但是所有列都被命名为item,item,item。现在,如果我想提及数字,例如item1 item2 item3,依此类推。我怎样才能做到这一点。

Rails的家伙

我不知道你#{l(:item)}在做什么 但您可以使用以下方法:

- if @product.type_id == 2
      %th.order_invoice_cell.each.count
        #{l(:item)}
      - @product.products.each_with_index do |p, index|
        %th.order_invoice_cell
          = "item #{index + 1}"

它将为您提供第1项,第2项,依此类推...谢谢

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章