This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-11-17 15:16:48 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: list_accounts
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# list_id :integer not null
|
|
|
|
# account_id :integer not null
|
|
|
|
# follow_id :integer not null
|
|
|
|
#
|
|
|
|
|
|
|
|
class ListAccount < ApplicationRecord
|
|
|
|
belongs_to :list, required: true
|
|
|
|
belongs_to :account, required: true
|
|
|
|
belongs_to :follow, required: true
|
|
|
|
|
2017-12-05 14:02:27 -08:00
|
|
|
validates :account_id, uniqueness: { scope: :list_id }
|
|
|
|
|
2017-11-17 15:16:48 -08:00
|
|
|
before_validation :set_follow
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_follow
|
|
|
|
self.follow = Follow.find_by(account_id: list.account_id, target_account_id: account.id)
|
|
|
|
end
|
|
|
|
end
|