railsadminteam/rails_admin · error · ArgumentError

Search operator '#{operator}' not supported

Error message

Search operator '#{operator}' not supported

What it means

RailsAdmin::Config#default_search_operator= (lib/rails_admin/config.rb:203) sets the operator used to match the query string typed in the index-screen search box against searchable columns. It validates the value against the whitelist %w[default like not_like starts_with ends_with is =] and raises ArgumentError for anything else, at boot time, inside the initializer.

Source

Thrown at lib/rails_admin/config.rb:210

      #
      # @example Custom
      #   RailsAdmin.config do |config|
      #     config.current_user_method do
      #       current_admin
      #     end
      #   end
      #
      # @see RailsAdmin::Config::DEFAULT_CURRENT_USER
      def current_user_method(&block)
        @current_user = block if block
        @current_user || DEFAULT_CURRENT_USER
      end

      def default_search_operator=(operator)
        if %w[default like not_like starts_with ends_with is =].include? operator
          @default_search_operator = operator
        else
          raise ArgumentError.new("Search operator '#{operator}' not supported")
        end
      end

      # pool of all found model names from the whole application
      def models_pool
        (viable_models - excluded_models.collect(&:to_s)).uniq.sort
      end

      # Loads a model configuration instance from the registry or registers
      # a new one if one is yet to be added.
      #
      # First argument can be an instance of requested model, its class object,
      # its class name as a string or symbol or a RailsAdmin::AbstractModel
      # instance.
      #
      # If a block is given it is evaluated in the context of configuration instance.
      #
      # Returns given model's configuration

View on GitHub (pinned to 0690a5e62f)

Solutions

  1. Use one of the supported values: 'default', 'like', 'not_like', 'starts_with', 'ends_with', 'is', or '=' — most apps that had 'contains' want 'like' (default 'default' performs the per-column smart matching).
  2. If you removed the line, remember 'default' is the built-in default operator and usually needs no configuration at all.
  3. Re-run the failing command (rails runner/console) to confirm the initializer now evaluates cleanly.

Example fix

# before (raises ArgumentError at boot)
RailsAdmin.config do |config|
  config.default_search_operator = 'contains'
end

# after
RailsAdmin.config do |config|
  config.default_search_operator = 'like' # one of: default like not_like starts_with ends_with is =
end
Defensive patterns

Strategy: validation

Validate before calling

# Validate before assigning, e.g. in a reusable initializer helper
ALLOWED = %w[default like not_like starts_with ends_with is =].freeze
op = ENV['RAILS_ADMIN_SEARCH_OP'] || 'like'
unless ALLOWED.include?(op)
  raise ArgumentError, "#{op.inspect} not in #{ALLOWED.join(', ')}"
end
RailsAdmin.config { |c| c.default_search_operator = op }

Type guard

SUPPORTED_SEARCH_OPERATORS = %w[default like not_like starts_with ends_with is =].freeze
valid_search_operator = ->(op) { SUPPORTED_SEARCH_OPERATORS.include?(op.to_s.downcase) }

Prevention

When it happens

Trigger: Setting RailsAdmin.config.default_search_operator to a value outside the whitelist, e.g. 'contains', 'ilike', '=~', 'matches', 'was', or a typo like 'Starts_With'. Raised the moment the initializer block is evaluated, so `rails server`, `rails console`, and asset precompile all fail with this ArgumentError.

Common situations: Copy-pasting an initializer from a blog post or another admin gem that uses different operator names; assuming SQL/AREL operator syntax; upgrading an old rails_admin initializer whose operator vocabulary no longer matches; leftover CI config using an operator removed in a previous version.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


AI-assisted analysis of railsadminteam/rails_admin@0690a5e62f (2026-08-21). Data as JSON: /api/errors/e1b48de66098124a. Report an issue: GitHub.