mirror of https://github.com/rails/rails
Merge pull request #16851 from prathamesh-sonpatki/mention-validate-in-upgrade-guide
Update error message of Active Model's validate method
This commit is contained in:
commit
b52add7e17
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue