0

I'm trying to color some rows in a rails table based on a single attribute. I'm only specifying that so people don't get confused, thinking I'm trying to alternate the colors in my table. That's not the goal. Thing is, it worked 20 minutes ago, %tr.error and %tr.warning in my haml file colored the rows correctly (using bootstrap), but now they don't do anything. I'm seeing questions on here about how sorting tables can mess up coloring. I'm using thinking-sphinx as a search engine for my app. Could that be the problem? If so, is there a way to fix this without getting my hands too dirty in Javascript? (it's not really my strong suit)

EDIT: 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

I was trying to add in a partial to ease out a lot of repetition and that was when stuff started breaking.

Brad Rice
  • 1,334
  • 2
  • 17
  • 36
  • 1
    You should use your browser debugging tools to check that the classes you set are present in your rendered HTML. If they are, then it sounds like a CSS problem. If they're not, you'll have to post some code so we can help track down where the issue is. –  Jan 08 '13 at 04:58
  • I would say this has nothing to do with javascript. The classes on the rows could be messed up, or the bootstrap css may not be loading properly at all. Or there are some rules in some css overriding the bootstrap stuff. Do you have some html or something else to help with? – neouser99 Jan 08 '13 at 04:58
  • @Issac, I verified the classes exist. I can show()/hide() them at will. Just have no clue how to make them style. Thanks for the start! neouser99, I posted up my view. I was playing around with partials and think I may have broken something that way. All in all I'm stumped. – Brad Rice Jan 08 '13 at 05:12
  • Can you show the HTML output that RoR displays? Maybe something in the HTML will help us narrow down the problem. – ckpepper02 Aug 16 '13 at 14:11

0 Answers0