logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

list_account.rb (589B)


  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
  13. belongs_to :account
  14. belongs_to :follow
  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