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.
2018-08-09 00:56:53 -07:00
|
|
|
# frozen_string_literal: true
|
2023-02-19 21:58:28 -08:00
|
|
|
|
2018-08-09 00:56:53 -07:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: account_pins
|
|
|
|
#
|
|
|
|
# id :bigint(8) not null, primary key
|
|
|
|
# account_id :bigint(8)
|
|
|
|
# target_account_id :bigint(8)
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
#
|
|
|
|
|
|
|
|
class AccountPin < ApplicationRecord
|
2018-08-20 09:46:04 -07:00
|
|
|
include Paginable
|
2018-08-09 00:56:53 -07:00
|
|
|
include RelationshipCacheable
|
|
|
|
|
|
|
|
belongs_to :account
|
|
|
|
belongs_to :target_account, class_name: 'Account'
|
|
|
|
|
|
|
|
validate :validate_follow_relationship
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def validate_follow_relationship
|
|
|
|
errors.add(:base, I18n.t('accounts.pin_errors.following')) unless account.following?(target_account)
|
|
|
|
end
|
|
|
|
end
|