From f2404de871f0bdfda5c9aeeeb4c6c4d10a8da8ab Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 9 Aug 2018 09:56:53 +0200 Subject: Public profile endorsements (accounts picked by profile owner) (#8146) --- app/models/account_pin.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/models/account_pin.rb (limited to 'app/models/account_pin.rb') diff --git a/app/models/account_pin.rb b/app/models/account_pin.rb new file mode 100644 index 000000000..9a21c3405 --- /dev/null +++ b/app/models/account_pin.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true +# == 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 + 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 -- cgit