From 487d81fb92350974e20ee220553a10b5229f0880 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 25 Oct 2022 21:43:44 +0200 Subject: Fix IP blocks not having a unique index (#19456) --- app/controllers/admin/ip_blocks_controller.rb | 2 +- app/models/ip_block.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/admin/ip_blocks_controller.rb b/app/controllers/admin/ip_blocks_controller.rb index a87520f4e..1bd7ec805 100644 --- a/app/controllers/admin/ip_blocks_controller.rb +++ b/app/controllers/admin/ip_blocks_controller.rb @@ -5,7 +5,7 @@ module Admin def index authorize :ip_block, :index? - @ip_blocks = IpBlock.page(params[:page]) + @ip_blocks = IpBlock.order(ip: :asc).page(params[:page]) @form = Form::IpBlockBatch.new end diff --git a/app/models/ip_block.rb b/app/models/ip_block.rb index 8666f4248..31343f0e1 100644 --- a/app/models/ip_block.rb +++ b/app/models/ip_block.rb @@ -25,6 +25,7 @@ class IpBlock < ApplicationRecord } validates :ip, :severity, presence: true + validates :ip, uniqueness: true after_commit :reset_cache -- cgit