Skip to content

Fix missing_presence_validation crash when inclusion/exclusion :in is a method name#243

Open
SAY-5 wants to merge 1 commit into
gregnavis:masterfrom
SAY-5:fix-presence-validation-symbol-in
Open

Fix missing_presence_validation crash when inclusion/exclusion :in is a method name#243
SAY-5 wants to merge 1 commit into
gregnavis:masterfrom
SAY-5:fix-presence-validation-symbol-in

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 18, 2026

Copy link
Copy Markdown

Fixes #238.

missing_presence_validation crashes when an inclusion or exclusion validator uses a method name for :in, e.g. validates :status, inclusion: { in: :allowed_statuses }. In that case validator.options[:in] is a Symbol, and the detector calls .exclude? / .include? on it, raising NoMethodError: undefined method 'exclude?' for an instance of Symbol.

A Symbol :in is resolved at validation time, just like a Proc, so the allowed values aren't known statically. This treats it the same way the Proc case is already handled instead of assuming the value responds to include?/exclude?.

… a method name

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

missing_presence_validation crashes with NoMethodError: undefined method 'exclude?' for Symbol

1 participant