From f0a16f20051c6c5ac6a1942a280cc4c15d671096 Mon Sep 17 00:00:00 2001 From: Sammy Larbi Date: Thu, 28 Apr 2016 10:29:55 -0500 Subject: [PATCH] @options.fetch(:errors, {}) can be nil If the key `:errors` exists in `@options` then the previous code will return `nil`. Changing it like this ensures we have a hash if errors did not exist or if it was nil. --- lib/bh/core_ext/rails/form/base_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bh/core_ext/rails/form/base_helper.rb b/lib/bh/core_ext/rails/form/base_helper.rb index 3b2b71f..c5ca813 100644 --- a/lib/bh/core_ext/rails/form/base_helper.rb +++ b/lib/bh/core_ext/rails/form/base_helper.rb @@ -75,7 +75,7 @@ def label_and_field_container(label_and_field, field_type, errors = {}) def show_error_icon?(field_type, errors, suffix = nil) no_icon = %w(checkbox number_field radio_button select legend) hide = no_icon.include?(field_type.to_s) - errors.any? && @options.fetch(:errors, {}).fetch(:icons, true) && !hide && suffix.nil? + errors.any? && (@options.fetch(:errors) || {}).fetch(:icons, true) && !hide && suffix.nil? end def error_icon_tag