如何在表值更改时更改 bootstrap tr class?

how to change bootstrap tr class when tables value is changed?

我得到了bootstraptable

  table.table.table-striped.table-bordered
    thead
      th Test name
      th status
      th error message
      th

    tbody
      - @testrun.testcase.reject(&:empty?).each do |i|
        tr class=["" ]
          td = "#{i}"
          td = @testrun.testcases_output["#{i}"]["status"]
          td = @testrun.testcases_output["#{i}"]["error_message"]
          td
            a href='/log'
              | log

测试用例状态通过测试 运行 从 "In queue" 更改为 "Success" 或 "Failed"。当状态发生变化时,我需要将 tr class 更改为 danger/success/primary。有什么办法吗?

这是一个可能的解决方案

  - @testrun.testcase.reject(&:empty?).each do |i|
    - trClass = ""
    - trClass = "danger" if @testrun.testcases_output["#{i}"]["status"]=="Failed"
    - trClass = "success" if @testrun.testcases_output["#{i}"]["status"]=="Success"
    tr{class: trClass} 
      td = "#{i}"