aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/validations.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 7ee033ba5f..08c2b02f19 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -142,9 +142,14 @@ module ActiveModel
# value.
def validate(*args, &block)
options = args.extract_options!
+ valid_keys = [:on, :if, :unless]
if args.all? { |arg| arg.is_a?(Symbol) }
- options.assert_valid_keys([:on, :if, :unless])
+ options.each_key do |k|
+ unless valid_keys.include?(k)
+ raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}. Perhaps you meant to call validates instead of validate.")
+ end
+ end
end
if options.key?(:on)