* Wip: make web backend * Wip: keep statuses if edit circle * Wip: Add circle history page and record circle posts * Add circle post to history in web ui when post * Add test
31 lines
891 B
Ruby
31 lines
891 B
Ruby
# frozen_string_literal: true
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: circles
|
|
#
|
|
# id :bigint(8) not null, primary key
|
|
# account_id :bigint(8) not null
|
|
# title :string default(""), not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
|
|
class Circle < ApplicationRecord
|
|
include Paginable
|
|
|
|
PER_ACCOUNT_LIMIT = 100
|
|
|
|
belongs_to :account
|
|
|
|
has_many :circle_accounts, inverse_of: :circle, dependent: :destroy
|
|
has_many :accounts, through: :circle_accounts
|
|
has_many :circle_statuses, inverse_of: :circle, dependent: :destroy
|
|
has_many :statuses, through: :circle_statuses
|
|
|
|
validates :title, presence: true
|
|
|
|
validates_each :account_id, on: :create do |record, _attr, value|
|
|
record.errors.add(:base, I18n.t('lists.errors.limit')) if Circle.where(account_id: value).count >= PER_ACCOUNT_LIMIT
|
|
end
|
|
end
|