mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
properly deprecate #{type}_validation_on_#{on}
This commit is contained in:
@@ -44,6 +44,20 @@ module ActiveModel
|
||||
options[:if] << "self.validation_context == :#{options[:on]}" if options[:on]
|
||||
set_callback(:validation, :after, *(args << options), &block)
|
||||
end
|
||||
|
||||
[:before, :after].each do |type|
|
||||
[:create, :update].each do |on|
|
||||
class_eval <<-RUBY
|
||||
def #{type}_validation_on_#{on}(*args, &block)
|
||||
msg = "#{type}_validation_on_#{on} is deprecated. Please use #{type}_validation(arguments, :on => :#{on}"
|
||||
ActiveSupport::Deprecation.warn(msg, caller)
|
||||
options = args.extract_options!
|
||||
options[:on] = :#{on}
|
||||
before_validation(args.push(options), &block)
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
Reference in New Issue
Block a user