mongodb/mongoid · error

Creating scope :#{name} which conflicts with #{self.name}.#{

Error message

Creating scope :#{name} which conflicts with #{self.name}.#{name}. Calls to `Mongoid::Criteria##{name}` will delegate to `Mongoid::Criteria##{name}` for criteria with klass #{self.name} and will ignore the declared scope.

What it means

Error "Creating scope :#{name} which conflicts with #{self.name}.#{name}. Calls to `Mongoid::Criteria##{name}` will delegate to `Mongoid::Criteria##{name}` for criteria with klass #{self.name} and will ignore the declared scope." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/scopable.rb:246

      private

      # Warns or raises exception if overriding another scope or method.
      #
      # @api private
      #
      # @example Warn or raise error if name exists.
      #   Model.check_scope_name("test")
      #
      # @param [ String | Symbol ] name The name of the scope.
      #
      # @raise [ Errors::ScopeOverwrite ] If the name exists and configured to
      #   raise the error.
      def check_scope_name(name)
        return unless _declared_scopes[name] || respond_to?(name, true)
        raise Errors::ScopeOverwrite.new(self.name, name) if Mongoid.scope_overwrite_exception

        Mongoid.logger.warn(
          "Creating scope :#{name} which conflicts with #{self.name}.#{name}. " +
          "Calls to `Mongoid::Criteria##{name}` will delegate to " +
          "`Mongoid::Criteria##{name}` for criteria with klass #{self.name} " +
          'and will ignore the declared scope.'
        )
      end

      # Checks if the intended scope is a valid object, either a criteria or
      # proc with a criteria.
      #
      # @api private
      #
      # @example Check if the scope is valid.
      #   Model.check_scope_validity({})
      #
      # @param [ Object ] value The intended scope.
      #
      # @raise [ Errors::InvalidScope ] If the scope is not a valid object.

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/scopable.rb:246 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23). Data as JSON: /api/errors/7585554331fbe28e. Report an issue: GitHub.