diff options
author | claudiob <claudiob@gmail.com> | 2014-12-14 22:10:15 -0800 |
---|---|---|
committer | claudiob <claudiob@gmail.com> | 2015-01-02 15:31:56 -0800 |
commit | bb78af73ab7e86fd9662e8810e346b082a1ae193 (patch) | |
tree | eef33ea8ee271af92d621fe68155f169d51b5a65 /activerecord/lib/active_record/callbacks.rb | |
parent | 91b8129320522f664801f122daea4a7628db90a7 (diff) | |
download | rails-bb78af73ab7e86fd9662e8810e346b082a1ae193.tar.gz rails-bb78af73ab7e86fd9662e8810e346b082a1ae193.tar.bz2 rails-bb78af73ab7e86fd9662e8810e346b082a1ae193.zip |
Deprecate `false` as the way to halt AR callbacks
Before this commit, returning `false` in an ActiveRecord `before_` callback
such as `before_create` would halt the callback chain.
After this commit, the behavior is deprecated: will still work until
the next release of Rails but will also display a deprecation warning.
The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
Diffstat (limited to 'activerecord/lib/active_record/callbacks.rb')
-rw-r--r-- | activerecord/lib/active_record/callbacks.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index 497ce8c15c..f44e5af5de 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -192,14 +192,14 @@ module ActiveRecord # # == <tt>before_validation*</tt> returning statements # - # If the returning value of a +before_validation+ callback can be evaluated to +false+, the process will be + # If the +before_validation+ callback throws +:abort+, the process will be # aborted and <tt>Base#save</tt> will return +false+. If Base#save! is called it will raise a # ActiveRecord::RecordInvalid exception. Nothing will be appended to the errors object. # # == Canceling callbacks # - # If a <tt>before_*</tt> callback returns +false+, all the later callbacks and the associated action are - # cancelled. If an <tt>after_*</tt> callback returns +false+, all the later callbacks are cancelled. + # If a <tt>before_*</tt> callback throws +:abort+, all the later callbacks and + # the associated action are cancelled. # Callbacks are generally run in the order they are defined, with the exception of callbacks defined as # methods on the model, which are called last. # |