2018-08-09 09:56:53 +02:00
|
|
|
# frozen_string_literal: true
|
2023-02-20 06:58:28 +01:00
|
|
|
|
2018-08-09 09:56:53 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: account_pins
|
|
|
|
#
|
|
|
|
# id :bigint(8) not null, primary key
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
2024-12-10 16:50:49 +01:00
|
|
|
# account_id :bigint(8) not null
|
|
|
|
# target_account_id :bigint(8) not null
|
2018-08-09 09:56:53 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
class AccountPin < ApplicationRecord
|
2018-08-20 18:46:04 +02:00
|
|
|
include Paginable
|
2018-08-09 09:56:53 +02:00
|
|
|
include RelationshipCacheable
|
|
|
|
|
|
|
|
belongs_to :account
|
|
|
|
belongs_to :target_account, class_name: 'Account'
|
|
|
|
|
|
|
|
validate :validate_follow_relationship
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def validate_follow_relationship
|
2024-12-10 14:02:52 +01:00
|
|
|
errors.add(:base, I18n.t('accounts.pin_errors.following')) unless account&.following?(target_account)
|
2018-08-09 09:56:53 +02:00
|
|
|
end
|
|
|
|
end
|