This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2017-11-18 00:16:48 +01: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 23:02:27 +01:00
|
|
|
validates :account_id, uniqueness: { scope: :list_id }
|
|
|
|
|
2017-11-18 00:16:48 +01: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
|