Growstuff/growstuff

View on GitHub
app/views/posts/_summary.html.haml

Summary

Maintainability
Test Coverage
- howmany ||= 100
- unless posts.empty?
  %table.table.table-striped
    %tr
      %th.col-6 Subject
      %th.col-2.hidden-xs Posted by
      %th.col-2 Most recent activity
      %th.col-2.hidden-xs Comments

    - posts.recently_active[0..howmany - 1].each do |post|
      - cache post do
        %tr
          %td
            = link_to truncate(strip_tags(post.subject), length: 40, separator: ' '), post
          %td.hidden-xs
            = link_to post.author, post.author
          %td
            - if post.updated_at > post.recent_activity
              %span{ title: post.updated_at.to_date.to_formatted_s(:long) }
                = post.updated_at.to_date.to_formatted_s(:short)
            - else
              %span{ title: post.recent_activity.to_date.to_formatted_s(:long) }
                = post.recent_activity.to_date.to_formatted_s(:short)
            // once the site gets more active, can change this to include time as well
            // can't make it relative (distance_of_time_in_words) as it's cached
          %td.hidden-xs
            = post.comments.size.to_s