From 2f4c5f504fa5edc2a826afa9645371f529ae904d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 9 Dec 2017 01:32:29 +0100 Subject: Limit users to 50 lists, remove pagination from lists API (#5933) --- app/models/list.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/models') diff --git a/app/models/list.rb b/app/models/list.rb index 910864b26..f45e4973d 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -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 -- cgit