From 5664cd3ca8bdc79fa44c75b41bbfadbc8a2c1856 Mon Sep 17 00:00:00 2001 From: Michael Kohl Date: Tue, 10 Nov 2020 08:47:30 +0700 Subject: [PATCH] Correctly set constant in including modules (#11331) --- app/models/concerns/acts_as_profile_field.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/acts_as_profile_field.rb b/app/models/concerns/acts_as_profile_field.rb index 74c5c1e98..8686fa42b 100644 --- a/app/models/concerns/acts_as_profile_field.rb +++ b/app/models/concerns/acts_as_profile_field.rb @@ -1,10 +1,12 @@ # Used for sharing behavior between ProfileField and CustomProfileField -concern :ActsAsProfileField do +module ActsAsProfileField + extend ActiveSupport::Concern + + WORD_REGEX = /\w+/.freeze + included do before_create :generate_attribute_name - WORD_REGEX = /\w+/.freeze # rubocop:disable Lint/ConstantDefinitionInBlock - validates :label, presence: true, uniqueness: { case_sensitive: false } validates :attribute_name, presence: true, on: :update end