osu-cascades/ecotone-web

View on GitHub
app/views/plants/index.html.haml

Summary

Maintainability
Test Coverage
- content_for_title('All Plants')
- content_for(:subnav) do
  = link_to('Add Plant', new_plant_path, class: 'button primary', title: 'Add a new plant', method: 'get') if current_user&.admin?
.gallery
  - @plants.each do |plant|
    .tile#plant
      - if plant.photo.attached?
        .img-tile{ :style => "background-image: url(#{rails_blob_url(photo(plant))})", :alt => "Photo of #{plant.photo}" }
      -else
        .img-tile.default
          = image_tag(photo(plant), alt: "Photo of #{plant.photo}")
      .desc
        %h3= plant.common_name.titleize.truncate_words(2)
        %p.italic= plant.scientific_name.capitalize.truncate_words(2)
      = link_to "", plant, title: "Details of #{plant}", class: "tile-link"