Search code examples
ruby-on-railsbootstrap-4slim-lang

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


I got bootstrap table

  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

testcase statuses changes through test run from "In queue" to "Success" or "Failed". And I need to change tr class to danger/success/primary, when statuses is change. There is any way how can I do it?


Solution

  • this is a posssible solution

      - @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}"