aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/validations/callbacks.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/callbacks.rb b/activemodel/lib/active_model/validations/callbacks.rb
index bf3fe7ff04..c59babd831 100644
--- a/activemodel/lib/active_model/validations/callbacks.rb
+++ b/activemodel/lib/active_model/validations/callbacks.rb
@@ -56,7 +56,8 @@ module ActiveModel
options = args.last
if options.is_a?(Hash) && options[:on]
options[:if] = Array(options[:if])
- options[:if].unshift("self.validation_context == :#{options[:on]}")
+ options[:on] = Array(options[:on])
+ options[:if].unshift("self.validation_context.in? #{options[:on]}")
end
set_callback(:validation, :before, *args, &block)
end
@@ -92,7 +93,10 @@ module ActiveModel
options = args.extract_options!
options[:prepend] = true
options[:if] = Array(options[:if])
- options[:if].unshift("self.validation_context == :#{options[:on]}") if options[:on]
+ if options[:on]
+ options[:on] = Array(options[:on])
+ options[:if].unshift("self.validation_context.in? #{options[:on]}")
+ end
set_callback(:validation, :after, *(args << options), &block)
end
end