From 258a2c1489ea0511d8e428770f40890517eeb309 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Fri, 4 Dec 2020 16:23:31 -0800 Subject: [PATCH] Fix Frozen String Error in Commercials Controller `errors_text` is a frozen string, so `<<` leads to an exception when trying to generate the error message. https://sentry.cs10.org/share/issue/7867fdaf8eba4387ae2789fd5f1cff3b/ if you want a production example. :) --- app/controllers/admin/commercials_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index e361086d..66a1d8d7 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -65,8 +65,8 @@ module Admin flash[:notice] = 'Successfully added commercials.' else errors_text = '' - errors_text << 'Unable to find event with ID: ' + errors[:no_event].join(', ') + '. ' if errors[:no_event].any? - errors_text << 'There were some errors: ' + errors[:validation_errors].join('. ') if errors[:validation_errors].any? + errors_text += 'Unable to find event with ID: ' + errors[:no_event].join(', ') + '. ' if errors[:no_event].any? + errors_text += 'There were some errors: ' + errors[:validation_errors].join('. ') if errors[:validation_errors].any? flash[:error] = errors_text end