我正在尝试根据单个属性为rails表中的某些行着色。我只是说明了这一点,所以人们不会感到困惑,以为我正试图改变我表中的颜色。那不是目标。事情是,它在20分钟前工作,我的haml文件中的%tr.error
和%tr.warning
正确地将行着色(使用引导程序),但现在它们什么也没做。我在这里看到有关排序表如何搞乱着色的问题。我正在使用think-sphinx作为我的应用程序的搜索引擎。这可能是问题吗?如果是这样,有没有办法解决这个问题,而不是让我的手在Javascript中太脏? (这不是我的强项)
编辑:movies / 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
我试图添加一部分以减轻重复次数,这就是当事情开始破碎时。