diff options
author | David Yip <yipdw@member.fsf.org> | 2017-12-12 02:54:13 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-12-12 02:54:13 -0600 |
commit | a057ed5cfea2c1c4fb21984cadae993740fb25e0 (patch) | |
tree | c965f135b8c46f679eb22e80a37550c8b985b9ea /app/models/list.rb | |
parent | 04eaa1943f002865f8a0234e19c6ea4cc1d3bb6a (diff) | |
parent | 14c4a33cd9bfc1212cb362897272e5ea7d1529e5 (diff) |
Merge remote-tracking branch 'tootsuite/master' into merge-upstream
Diffstat (limited to 'app/models/list.rb')
-rw-r--r-- | app/models/list.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/list.rb b/app/models/list.rb index 910864b26..be85c3b87 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -4,7 +4,7 @@ # Table name: lists # # id :integer not null, primary key -# account_id :integer +# account_id :integer not null # title :string default(""), not null # created_at :datetime not null # updated_at :datetime not null @@ -13,6 +13,8 @@ class List < ApplicationRecord include Paginable + PER_ACCOUNT_LIMIT = 50 + belongs_to :account has_many :list_accounts, inverse_of: :list, dependent: :destroy @@ -20,6 +22,10 @@ class List < ApplicationRecord validates :title, presence: true + validates_each :account_id, on: :create do |record, _attr, value| + record.errors.add(:base, I18n.t('lists.errors.limit')) if List.where(account_id: value).count >= PER_ACCOUNT_LIMIT + end + before_destroy :clean_feed_manager private |