mongodb/mongoid · error · Mongoid::Errors::InvalidStorageOptions

Invalid options passed to %{klass}.store_in: %{options}.

Error message

Invalid options passed to %{klass}.store_in: %{options}.

What it means

Error "Invalid options passed to %{klass}.store_in: %{options}." thrown in mongodb/mongoid.

Source

Thrown at lib/mongoid/clients/validators/storage.rb:21

module Mongoid
  module Clients
    module Validators
      # Validates the options passed to :store_in.
      module Storage
        extend self

        # The valid options for storage.
        VALID_OPTIONS = %i[collection collection_options database client].freeze

        # Validate the options provided to :store_in.
        #
        # @example Validate the options.
        #   Storage.validate(:collection_name)
        #
        # @param [ Class ] klass The model class.
        # @param [ Hash | String | Symbol ] options The provided options.
        def validate(klass, options)
          valid_keys?(options) or raise Errors::InvalidStorageOptions.new(klass, options)
        end

        private

        # Determine if all keys in the options hash are valid.
        #
        # @api private
        #
        # @example Are all keys valid?
        #   validator.valid_keys?({ collection: "name" })
        #
        # @param [ Hash ] options The options hash.
        #
        # @return [ true | false ] If all keys are valid.
        def valid_keys?(options)
          return false unless options.is_a?(::Hash)

          options.keys.all? do |key|

View on GitHub (pinned to 0da0e23d71)

When it happens

Trigger: Thrown at lib/mongoid/clients/validators/storage.rb:21 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/8cef3cfa7301c8e7. Report an issue: GitHub.