<commit_before>module Spree
  class Kit < Spree::Base
    extend FriendlyId

    has_many :spree_kits_products, -> { order(:position) }, class_name: "Spree::KitProduct"
    has_many :spree_kits_lookbooks, class_name: "Spree::KitLookbook"
    has_many :products, :through => 'spree_kits_products', class_name: "Spree::Product"
    has_many :lookbooks, :through => 'spree_kits_lookbooks', class_name: "Spree::Lookbook"

    translates :name, :slug, presence: true
    accepts_nested_attributes_for :translations, :spree_kits_products, allow_destroy: true


    has_attached_file :image,

                      styles: { mini: '32x32>', normal: '128x128>', large: '1100x467' },
                      default_style: :large
    validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]

    friendly_id :slug_candidates, use: :globalize

    def slug_candidates
      [[:name]]
    end
    def image_for product
      skp = spree_kits_products.where(product: product).first
      if skp && skp.image?
         skp.image.url(:large)
      else
        if product.images.empty?
          "noimage/product.png"
          unless product.variants.joins(:images).any?
            return "noimage/product.png"
          end
          return product.variants.joins(:images).first.images.first.url(:large)
        else
          image = product.images.first
          image.attachment.url(:large)
        end
      end
    end

  end
end

<commit_msg>spree has attachment on image<commit_after>module Spree
  class Kit < Spree::Base
    extend FriendlyId

    has_many :spree_kits_products, -> { order(:position) }, class_name: "Spree::KitProduct"
    has_many :spree_kits_lookbooks, class_name: "Spree::KitLookbook"
    has_many :products, :through => 'spree_kits_products', class_name: "Spree::Product"
    has_many :lookbooks, :through => 'spree_kits_lookbooks', class_name: "Spree::Lookbook"

    translates :name, :slug, presence: true
    accepts_nested_attributes_for :translations, :spree_kits_products, allow_destroy: true


    has_attached_file :image,

                      styles: { mini: '32x32>', normal: '128x128>', large: '1100x467' },
                      default_style: :large
    validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]

    friendly_id :slug_candidates, use: :globalize

    def slug_candidates
      [[:name]]
    end
    def image_for product
      skp = spree_kits_products.where(product: product).first
      if skp && skp.image?
         skp.image.url(:large)
      else
        if product.images.empty?
          "noimage/product.png"
          unless product.variants.joins(:images).any?
            return "noimage/product.png"
          end
          return product.variants.joins(:images).first.images.first.attachment.url(:large)
        else
          image = product.images.first
          image.attachment.url(:large)
        end
      end
    end

  end
end


{'fraction_non_alphanumeric': 0.11258718033875789, 'fraction_numerical': 0.011291929591497841, 'mean_word_length': 2.901554404145078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3589421', 'n_tokens_mistral': 988, 'n_tokens_neox': 946, 'n_words': 192}