<commit_before>class User < ActiveRecord::Base
  has_secure_password
  has_many :memories
  has_many :memberships
  has_many :families, :through => :memberships, :dependent => :destroy
  # has_many :families, :foreign_key => "family_id", :class_name => "Membership", :dependent => :destroy

# same relationship as line 5
  # has_many :families, :through => :memberships, :dependent => :destroy

# pulls only authorized members
  # has_many :authorized_members, :through => :memberships, :source => :family, :conditions => [ "authorized = ?", true]

# pulls unauthorized members
  # has_many :unauthorized_members, :through => :memberships, :source => :family, :conditions => [ "authorized = ?", false]



  validates :password, confirmation: true

  def add_family(member)
    # binding.pry
    a = Membership.new(user_id: self.id, family_id: member.id)
    if a.save
      p "goot it"
    end
    b = Membership.new(user_id: member.id, family_id: self.id)
    if b.save
      p "got b done"
    end
  end
end<commit_msg>can remove and add family member<commit_after>class User < ActiveRecord::Base
  has_secure_password
  has_many :memories
  has_many :memberships
  has_many :families, :through => :memberships, :dependent => :destroy
  # has_many :families, :foreign_key => "family_id", :class_name => "Membership", :dependent => :destroy

# same relationship as line 5
  # has_many :families, :through => :memberships, :dependent => :destroy

# pulls only authorized members
  # has_many :authorized_members, :through => :memberships, :source => :family, :conditions => [ "authorized = ?", true]

# pulls unauthorized members
  # has_many :unauthorized_members, :through => :memberships, :source => :family, :conditions => [ "authorized = ?", false]



  validates :password, confirmation: true

  def add_family(member)
    # binding.pry
    a = Membership.new(user_id: self.id, family_id: member.id)
    if a.save
      p "User to New member DONE!"
    end
    b = Membership.new(user_id: member.id, family_id: self.id)
    if b.save
      p "Member Can see User DONE!"
    end
  end

  def remove_family(member)
    # binding.pry
    a = Membership.find_by(user_id: self.id, family_id: member.id)
    if a.delete
      p "Remove User to Family Member"
    end
    b = Membership.find_by(user_id: member.id, family_id: self.id)
    if b.delete
      p "Remove Family Member to User"
    end
  end



end
{'fraction_non_alphanumeric': 0.12038190120381902, 'fraction_numerical': 0.0008302200083022001, 'mean_word_length': 3.8490945674044266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '5599695', 'n_tokens_mistral': 801, 'n_tokens_neox': 761, 'n_words': 221}