about summary refs log tree commit diff
path: root/app/controllers/admin/domain_blocks_controller.rb
blob: a8b56c0859b3498dbee132101f80b1ecdd34138b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Admin
  class DomainBlocksController < BaseController
    def index
      @blocks = DomainBlock.page(params[:page])
    end

    def new
      @domain_block = DomainBlock.new
    end

    def create
      @domain_block = DomainBlock.new(resource_params)

      if @domain_block.save
        DomainBlockWorker.perform_async(@domain_block.id)
        redirect_to admin_domain_blocks_path, notice: 'Domain block is now being processed'
      else
        render action: :new
      end
    end

    private

    def resource_params
      params.require(:domain_block).permit(:domain, :severity)
    end
  end
end