From cc8fe115b22cb4f83ca0302886a34481551aea1d Mon Sep 17 00:00:00 2001 From: Daniel Abrahamsson Date: Wed, 28 Jul 2010 10:09:01 +0200 Subject: [PATCH] Fixed proper deprecation warning messages for validate_on_create and validate_on_update --- activerecord/lib/active_record/callbacks.rb | 5 +++-- activerecord/lib/active_record/validations.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index 637dac4..d3e7cb3 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -256,9 +256,10 @@ module ActiveRecord _run_destroy_callbacks { super } end - def deprecated_callback_method(symbol) #:nodoc: + def deprecated_callback_method(symbol, method_to_use = nil) #:nodoc: if respond_to?(symbol, true) - ActiveSupport::Deprecation.warn("Overwriting #{symbol} in your models has been deprecated, please use Base##{symbol} :method_name instead") + method_to_use ||= "#{symbol} :method_name" + ActiveSupport::Deprecation.warn("Overwriting #{symbol} in your models has been deprecated, please use Base##{method_to_use} instead") send(symbol) end end diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index b98fd35..5b04e2f 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -55,7 +55,7 @@ module ActiveRecord output = super(context) deprecated_callback_method(:validate) - deprecated_callback_method(:"validate_on_#{context}") + deprecated_callback_method(:"validate_on_#{context}", "validate :method_name, :on => #{context}") errors.empty? && output end -- 1.7.0.2.msysgit.0