如何在 HAML if 语句中更改 href

How to change href in HAML if statement

我的 workList 有 2 条不同的路径,它们都指向同一个地方。我希望他们走不同的路。这是我的代码:

%table.table-base.table-striped.table-hover{:id => "work-list-table"}
  %tbody
    - @work_list.each do |workList| //there are two items in this object
      %tr{:id => workList.id,href: duplicate_claims_work_lists_path, :style => "cursor:pointer", :onclick=>"workListTrActions(this)"}
      -if workList.work_list_name == "Provider Payments"
           //href = provider_payments_work_lists_path
        %td
          %ul.custom-ul
            %li
              %h4
                =workList.work_list_name

如您所见,我有两个项目 duplicate_claims_work_lists_path 的路径。我想将 href 更改为 provider_payments_work_lists_path 的路径。我可以在 if 语句中更改它吗?

最好将 url 分配给一个变量,然后在 tr 元素中使用它

- @work_list.each do |workList| //there are two items in this object
  - url = (workList.work_list_name == "Provider Payments") ? provider_payments_work_lists_path : duplicate_claims_work_lists_path
  %tr{:id => workList.id,href: url, :style => "cursor:pointer", :onclick=>"workListTrActions(this)"}