instance method detect_negative_enum_conditions!

Ruby on Rails 8.1.2

Since v6.0.6 Private

Available in: v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

detect_negative_enum_conditions!(method_names)

No documentation comment.

Parameters

method_names req
Source
# File activerecord/lib/active_record/enum.rb, line 415
      def detect_negative_enum_conditions!(method_names)
        return unless logger

        method_names.select { |m| m.start_with?("not_") }.each do |potential_not|
          inverted_form = potential_not.sub("not_", "")
          if method_names.include?(inverted_form)
            logger.warn "Enum element '#{potential_not}' in #{self.name} uses the prefix 'not_'." \
              " This has caused a conflict with auto generated negative scopes." \
              " Avoid using enum elements starting with 'not' where the positive form is also an element."
          end
        end
      end

Defined in activerecord/lib/active_record/enum.rb line 415 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Enum

Type at least 2 characters to search.

↑↓ navigate · open · esc close