0

我有一个包含三列的表格,并且很难在time_ago_in_words同一个单元格中添加跟随文档名称。

我尝试了几次不同的迭代都%td= document.name, time_ago_in_words(document.created_at)无济于事。

哈姆勒:

%table.table.table-striped
    %thead
      %tr
        %th Name
        %th Download Link
        %th  
    %tbody
      - @documents.each do |document|
        %tr
          %td= document.name
          %td= link_to "Download Document", document.attachment_url
          %td= button_to "Delete",  document, method: :delete, class: "btn btn-danger", confirm: "Are you sure that you wish to delete #{document.name}?"
4

1 回答 1

1

您可以在 HAML 中使用 ruby​​ 字符串插值:

%td="#{document.name}, #{time_ago_in_words(document.created_at)}"
于 2015-04-11T21:45:41.017 回答