0

我正在尝试根据单个属性为 rails 表中的某些行着色。我只是指定这样人们就不会感到困惑,以为我正在尝试交替表中的颜色。那不是目标。问题是,它在 20 分钟前工作,%tr.error并且%tr.warning在我的 haml 文件中正确着色了行(使用引导程序),但现在它们什么都不做。我在这里看到有关排序表如何弄乱颜色的问题。我正在使用thinking-sphinx 作为我的应用程序的搜索引擎。这可能是问题吗?如果是这样,有没有办法解决这个问题而不会让我的手在Javascript中太脏?(这真的不是我的强项)

编辑:电影/index.html.haml

    !!!
    %head
    %body
      %br
      = link_to "Sign out", signout_path, method: 'delete', class: "btn btn-primary"
      = link_to "View checked out", checked_path, class: "btn btn-primary"
      = link_to "Full index", root_path, class: "btn"
      = link_to "My movies", my_movies_path, class: "btn btn-primary"
      = link_to "Add a new movie", new_movie_path, class: "btn btn-success"
      %br
      %br
      = form_tag movies_path, method: 'get' do
        %p
          = text_field_tag :search, params[:search], placeholder: "Search by name or keyword"
          = submit_tag "Search", class: "btn btn-primary"
      = "Showing #{Movie.all.length} results"
      %br
      %br
      / %table.table.table-bordered
      /   %thead
      /     %tr.info
      /       %th Title
      /       %th Year
      /       %th Format
      /       %th Loanee
      /       %th Action
      /   %tbody
      /     = render partial: 'movies/table', collection: @movies, as: :m
      / = will_paginate
      %table.table.table-striped.table-bordered
        %thead
          %tr
            %th Title
            %th Year
            %th Format
            %th Loanee
            %th Action
        %tbody
          -@movies.each do |m|
            -unless m.loanee.blank?
              %tr.error
                %td
                  = m.title
                %td
                  = m.year
                %td
                  = m.rec_form
                %td
                  = m.loanee
                %td
                  = link_to 'Check in', edit_movie_path(m), {:class => "btn"}
            -else
              %tr
                %td
                  = m.title
                %td
                  = m.year
                %td
                  = m.rec_form
                %td
                  = m.loanee
                %td
                  = link_to 'Check out', edit_movie_path(m), {:class => "btn"}    
      = will_paginate

我试图添加部分内容以减轻大量重复,这就是事情开始破裂的时候。

4

0 回答 0