You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
637 B

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: list_accounts
  5. #
  6. # id :integer not null, primary key
  7. # list_id :integer not null
  8. # account_id :integer not null
  9. # follow_id :integer not null
  10. #
  11. class ListAccount < ApplicationRecord
  12. belongs_to :list, required: true
  13. belongs_to :account, required: true
  14. belongs_to :follow, required: 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)
  20. end
  21. end