From 1fa249bbe59ccf6c717156c74d3e7425bc0ae95d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 21 Nov 2017 23:48:58 +0200 Subject: [PATCH] Remove monkey patching #407 --- config/initializers/autolabel.rb | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 config/initializers/autolabel.rb diff --git a/config/initializers/autolabel.rb b/config/initializers/autolabel.rb deleted file mode 100644 index ad877d540..000000000 --- a/config/initializers/autolabel.rb +++ /dev/null @@ -1,30 +0,0 @@ -class ActionView::Helpers::FormBuilder - alias_method :orig_label, :label - - # add a 'required' CSS class to the field label if the field is required - # rubocop:disable Metrics/CyclomaticComplexity - # rubocop:disable Metrics/PerceivedComplexity - def label(method, content_or_options = nil, options = nil, &block) - if content_or_options && content_or_options.class == Hash - options = content_or_options - else - content = content_or_options - end - - # rubocop:disable Style/MultilineOperationIndentation - if object.class.respond_to?(:validators_on) && - object.class.validators_on(method).map(&:class).include?(ActiveRecord::Validations::PresenceValidator) - - if options.class != Hash - options = { class: 'required' } - else - options[:class] = ((options[:class] || "") + ' required').split(' ').uniq.join(' ') - end - end - # rubocop:enable Style/MultilineOperationIndentation - - orig_label(method, content, options || {}, &block) - end - # rubocop:enable Metrics/PerceivedComplexity - # rubocop:enable Metrics/CyclomaticComplexity -end