diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 0a2544bf..01e7cd6e 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -134,10 +134,10 @@ class ItemsController < ApplicationController # Also, PB items have some special handling: we group them by color, then # load example pet types for the colors that don't have paint brushes. @pb_items_by_color = @pb_items.group_by(&:pb_color). - sort_by { |color, items| color.name }.to_h + sort_by { |color, items| color&.name }.to_h - colors_without_thumbnails = - @pb_items_by_color.keys.reject(&:pb_item_thumbnail_url?) + colors_without_thumbnails = @pb_items_by_color.keys. + select(&:present?).reject(&:pb_item_thumbnail_url?) @pb_color_pet_types = colors_without_thumbnails.map do |color| # Infer the ideal species from the first item we can, then try to find a diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index df732572..6fd9cc71 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -64,27 +64,33 @@ %table.item-list{"data-group-type": "bundle"} %thead %td.thumbnail-cell - - if color.pb_item_thumbnail_url? + - if color&.pb_item_thumbnail_url? = image_tag color.pb_item_thumbnail_url, alt: "Item thumbnail for #{color.pb_item_name}" - - else + - elsif color = image_tag pet_type_image_url(@pb_color_pet_types[color], size: :face), srcset: ["#{pet_type_image_url(@pb_color_pet_types[color], size: :face_2x)} 2x"], alt: @pb_color_pet_types[color].human_name %th - #{color.pb_item_name || color.name.humanize} + - if color + #{color.pb_item_name || color.name.humanize} + - else + ??? New color (#{pluralize items.size, "item"}) %td.actions-cell - - if color.pb_item_name? + - if color&.pb_item_name? = button_link_to "Shops", shop_wizard_url_for(color.pb_item_name), target: "_blank", icon: search_icon = button_link_to "Trades", trading_post_url_for(color.pb_item_name), target: "_blank", icon: search_icon - - else + - elsif color .special-color-explanation Get via Lab Ray, morphing potions, etc. + - else + .special-color-explanation + We don't have info about this color yet. %tbody - items.each do |item| = render "item_list_row", item: