The code powering m.abunchtell.com https://m.abunchtell.com
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

27 líneas
627 B

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: list_accounts
  5. #
  6. # id :bigint(8) not null, primary key
  7. # list_id :bigint(8) not null
  8. # account_id :bigint(8) not null
  9. # follow_id :bigint(8)
  10. #
  11. class ListAccount < ApplicationRecord
  12. belongs_to :list
  13. belongs_to :account
  14. belongs_to :follow, optional: true
  15. validates :account_id, uniqueness: { scope: :list_id }
  16. before_validation :set_follow
  17. private
  18. def set_follow
  19. self.follow = Follow.find_by!(account_id: list.account_id, target_account_id: account.id) unless list.account_id == account.id
  20. end
  21. end