1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Switch to using include? on validation callbacks

This commit is contained in:
John Foley 2012-07-02 19:23:34 -06:00
parent d66d6076b2
commit 60c65ca8df

View file

@ -57,7 +57,7 @@ module ActiveModel
if options.is_a?(Hash) && options[:on]
options[:if] = Array(options[:if])
options[:on] = Array(options[:on])
options[:if].unshift("self.validation_context.in? #{options[:on]}")
options[:if].unshift("#{options[:on]}.include? self.validation_context")
end
set_callback(:validation, :before, *args, &block)
end
@ -95,7 +95,7 @@ module ActiveModel
options[:if] = Array(options[:if])
if options[:on]
options[:on] = Array(options[:on])
options[:if].unshift("self.validation_context.in? #{options[:on]}")
options[:if].unshift("#{options[:on]}.include? self.validation_context")
end
set_callback(:validation, :after, *(args << options), &block)
end