From a6e34404a2aa3adfe032ed5ba852750ae92decc4 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Thu, 1 Aug 2019 23:25:19 -0500 Subject: strip params --- app/controllers/admin/domain_blocks_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index d0858006a..afba387cc 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -6,14 +6,16 @@ module Admin def new authorize :domain_block, :create? - @domain_block = DomainBlock.new(domain: params[:_domain]) + @domain_block = DomainBlock.new(domain: params[:_domain].present? ? params[:_domain].strip : nil) end def create authorize :domain_block, :create? + resource_params[:domain].strip! if resource_params[:domain].present? + resource_params[:reason].strip! if resource_params[:reason].present? @domain_block = DomainBlock.new(resource_params) - existing_domain_block = resource_params[:domain].present? ? DomainBlock.find_by(domain: resource_params[:domain]) : nil + existing_domain_block = resource_params[:domain].present? ? DomainBlock.find_by(domain: resource_params[:domain].strip) : nil if existing_domain_block.present? @domain_block = existing_domain_block @@ -43,6 +45,7 @@ module Admin def update return destroy unless resource_params[:undo].to_i.zero? + resource_params[:reason].strip! if resource_params[:reason].present? authorize @domain_block, :update? @domain_block.update(resource_params.except(:domain, :undo)) changed = @domain_block.changed -- cgit