<commit_before># == Schema Information
#
# Table name: blackmail
#
#  id           :integer         not null, primary key
#  user_id      :integer         not null
#  title        :string(255)     not null
#  description  :string(255)     not null
#  victim_name  :string(255)     not null
#  victim_email :string(255)     not null
#  expired_at   :datetime
#  created_at   :datetime        not null
#  updated_at   :datetime        not null
#

class Blackmail < ActiveRecord::Base
  # Relations  
  belongs_to :user
  has_many :demands, dependent: :delete_all
  
  #this might fix the "expecting 'Demands' got 'Array' error when posting new blackmail:
  accepts_nested_attributes_for :demands, :reject_if => lambda { |a| a[:name].blank? }
  
  # Validations
  validates :victim_email, email: true
  #TODO: need to fix "split" in blackmail#new, until then, this breaks the code:
  #validate :at_least_one_demand
    
  private
  
  def at_least_one_demand
    unless demands.any?
      errors.add_to_base 'You must specify at least one demand.'
    end
  end
  
end<commit_msg>Got new blackmail form to insert into the blackmail database, and upload image to public/images, but splitting of demands is not working in blackmail#create<commit_after># == Schema Information
#
# Table name: blackmail
#
#  id           :integer         not null, primary key
#  user_id      :integer         not null
#  title        :string(255)     not null
#  description  :string(255)     not null
#  victim_name  :string(255)     not null
#  victim_email :string(255)     not null
#  expired_at   :datetime
#  created_at   :datetime        not null
#  updated_at   :datetime        not null
#

class Blackmail < ActiveRecord::Base
  # Relations  
  belongs_to :user
  has_many :demands, dependent: :delete_all
  
  #this might fix the "expecting 'Demands' got 'Array' error when posting new blackmail:
  accepts_nested_attributes_for :demands, :reject_if => lambda { |a| a[:name].blank? }
  
  # Validations
  validates :victim_email, email: true
  #TODO: need to fix "split" in blackmail#create, until then, this breaks the code:
  #validate :at_least_one_demand
    
  private
  
  def at_least_one_demand
    unless demands.any?
      errors.add_to_base 'You must specify at least one demand.'
    end
  end
  
end
{'fraction_non_alphanumeric': 0.0782608695652174, 'fraction_numerical': 0.010434782608695653, 'mean_word_length': 3.0297723292469354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2450466', 'n_tokens_mistral': 748, 'n_tokens_neox': 726, 'n_words': 236}