aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2015-12-16 13:54:02 -0200
committerRafael França <rafaelmfranca@gmail.com>2015-12-16 13:54:02 -0200
commitb7a7e82207efd24d685fc1325fb523f047ca2ce1 (patch)
tree4fdaf223271dcb9eed500ed184365bdc4b159629 /activerecord
parentcf01e4e797e0c9162686babbb670f84481305d98 (diff)
parent21f4017fd904532ebe4964481567d69636a711cf (diff)
downloadrails-b7a7e82207efd24d685fc1325fb523f047ca2ce1.tar.gz
rails-b7a7e82207efd24d685fc1325fb523f047ca2ce1.tar.bz2
rails-b7a7e82207efd24d685fc1325fb523f047ca2ce1.zip
Merge pull request #22598 from yui-knk/deprecate_string_callback
Deprecate passing string to define callback.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/callbacks.rb15
-rw-r--r--activerecord/test/cases/callbacks_test.rb2
2 files changed, 1 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 4058affec3..854f9776a3 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -175,21 +175,6 @@ module ActiveRecord
# end
# end
#
- # The callback macros usually accept a symbol for the method they're supposed to run, but you can also
- # pass a "method string", which will then be evaluated within the binding of the callback. Example:
- #
- # class Topic < ActiveRecord::Base
- # before_destroy 'self.class.delete_all "parent_id = #{id}"'
- # end
- #
- # Notice that single quotes (') are used so the <tt>#{id}</tt> part isn't evaluated until the callback
- # is triggered. Also note that these inline callbacks can be stacked just like the regular ones:
- #
- # class Topic < ActiveRecord::Base
- # before_destroy 'self.class.delete_all "parent_id = #{id}"',
- # 'puts "Evaluated after parents are destroyed"'
- # end
- #
# == <tt>before_validation*</tt> returning statements
#
# If the +before_validation+ callback throws +:abort+, the process will be
diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb
index 73ac30e547..4f70ae3a1d 100644
--- a/activerecord/test/cases/callbacks_test.rb
+++ b/activerecord/test/cases/callbacks_test.rb
@@ -33,7 +33,7 @@ class CallbackDeveloper < ActiveRecord::Base
ActiveRecord::Callbacks::CALLBACKS.each do |callback_method|
next if callback_method.to_s =~ /^around_/
define_callback_method(callback_method)
- send(callback_method, callback_string(callback_method))
+ ActiveSupport::Deprecation.silence { send(callback_method, callback_string(callback_method)) }
send(callback_method, callback_proc(callback_method))
send(callback_method, callback_object(callback_method))
send(callback_method) { |model| model.history << [callback_method, :block] }