<commit_before>class Product < ActiveRecord::Base
  belongs_to :category

  has_many :product_oils
  has_many :oils, through: :product_oils

  has_many :volume_costs, :dependent => :destroy

  validates :name, uniqueness: true
  validates :name, :description, presence: true

  before_save :naming_convention

  scope :hand_creams, -> { joins(:category).where('categories.name = ?', "Hand Creams") }
  scope :sprays, -> { joins(:category).where('categories.name = ?', "Sprays") }
  scope :lip_glosses, -> { joins(:category).where('categories.name = ?', "Lip Glosses") }
  scope :scrubs, -> { joins(:category).where('categories.name = ?', "Scrubs") }

  def volume_costs_attributes=(volume_costs_hashes)
    vc = []
    volume_costs_hashes.each do |i, attributes|
      vc << VolumeCost.find_or_create_by(attributes).id
    end
    self.volume_cost_ids = vc
  end

  def volumes_with_data
    volume_costs.where('volume > ? AND cost > ?', 0, 0)
  end

  def naming_convention
    self.name = self.name.capitalize
  end

end<commit_msg>Changed the name of the arguement for the custom attribute and changed the code of the custom attribute to better suite what I am doing<commit_after>class Product < ActiveRecord::Base
  belongs_to :category

  has_many :product_oils
  has_many :oils, through: :product_oils

  has_many :volume_costs, :dependent => :destroy

  validates :name, uniqueness: true
  validates :name, :description, presence: true

  before_save :naming_convention

  scope :hand_creams, -> { joins(:category).where('categories.name = ?', "Hand Creams") }
  scope :sprays, -> { joins(:category).where('categories.name = ?', "Sprays") }
  scope :lip_glosses, -> { joins(:category).where('categories.name = ?', "Lip Glosses") }
  scope :scrubs, -> { joins(:category).where('categories.name = ?', "Scrubs") }

  def volume_costs_attributes=(volume_costs_attributes)
    self.volume_costs.destroy_all
    volume_costs_attributes.each do |i, attributes|
      self.volume_costs << VolumeCost.find_or_create_by(attributes)
    end
  end

  def volumes_with_data
    volume_costs.where('volume > ? AND cost > ?', 0, 0)
  end

  def naming_convention
    self.name = self.name.capitalize
  end

end
{'fraction_non_alphanumeric': 0.12579473206176203, 'fraction_numerical': 0.0018165304268846503, 'mean_word_length': 4.439506172839506, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '2602428', 'n_tokens_mistral': 758, 'n_tokens_neox': 712, 'n_words': 163}