{"record":{"id":"e1b48de66098124a","repo":"railsadminteam/rails_admin","slug":"search-operator-operator-not-supported","errorCode":null,"errorMessage":"Search operator '#{operator}' not supported","messagePattern":"Search operator '#(.+?)' not supported","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/rails_admin/config.rb","lineNumber":210,"sourceCode":"      #\n      # @example Custom\n      #   RailsAdmin.config do |config|\n      #     config.current_user_method do\n      #       current_admin\n      #     end\n      #   end\n      #\n      # @see RailsAdmin::Config::DEFAULT_CURRENT_USER\n      def current_user_method(&block)\n        @current_user = block if block\n        @current_user || DEFAULT_CURRENT_USER\n      end\n\n      def default_search_operator=(operator)\n        if %w[default like not_like starts_with ends_with is =].include? operator\n          @default_search_operator = operator\n        else\n          raise ArgumentError.new(\"Search operator '#{operator}' not supported\")\n        end\n      end\n\n      # pool of all found model names from the whole application\n      def models_pool\n        (viable_models - excluded_models.collect(&:to_s)).uniq.sort\n      end\n\n      # Loads a model configuration instance from the registry or registers\n      # a new one if one is yet to be added.\n      #\n      # First argument can be an instance of requested model, its class object,\n      # its class name as a string or symbol or a RailsAdmin::AbstractModel\n      # instance.\n      #\n      # If a block is given it is evaluated in the context of configuration instance.\n      #\n      # Returns given model's configuration","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/railsadminteam/rails_admin/blob/0690a5e62f8d99bc00495a3754f5189b23124387/lib/rails_admin/config.rb#L192-L228","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","If you removed the line, remember 'default' is the built-in default operator and usually needs no configuration at all.","Re-run the failing command (rails runner/console) to confirm the initializer now evaluates cleanly."],"exampleFix":"# before (raises ArgumentError at boot)\nRailsAdmin.config do |config|\n  config.default_search_operator = 'contains'\nend\n\n# after\nRailsAdmin.config do |config|\n  config.default_search_operator = 'like' # one of: default like not_like starts_with ends_with is =\nend","handlingStrategy":"validation","validationCode":"# Validate before assigning, e.g. in a reusable initializer helper\nALLOWED = %w[default like not_like starts_with ends_with is =].freeze\nop = ENV['RAILS_ADMIN_SEARCH_OP'] || 'like'\nunless ALLOWED.include?(op)\n  raise ArgumentError, \"#{op.inspect} not in #{ALLOWED.join(', ')}\"\nend\nRailsAdmin.config { |c| c.default_search_operator = op }","typeGuard":"SUPPORTED_SEARCH_OPERATORS = %w[default like not_like starts_with ends_with is =].freeze\nvalid_search_operator = ->(op) { SUPPORTED_SEARCH_OPERATORS.include?(op.to_s.downcase) }","tryCatchPattern":null,"preventionTips":["Source the operator from a validated constant/ENV check rather than typing the string twice in the initializer.","Boot the app in CI (rails runner 'RailsAdmin.config.default_search_operator') so a bad initializer fails the build, not production deploys.","Check the rails_admin CHANGELOG for the operator whitelist whenever bumping the gem."],"tags":["rails-admin","configuration","search","argument-error","ruby","initializer"],"backgroundTag":"config-validation-failed","analyzedSha":"0690a5e62f8d99bc00495a3754f5189b23124387","analyzedAt":"2026-08-21T18:31:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}