diff options
author | Manoj <manoj.mk27@gmail.com> | 2012-01-28 00:18:59 +0530 |
---|---|---|
committer | Manoj <manoj.mk27@gmail.com> | 2012-01-29 15:28:22 +0530 |
commit | 336ff8a97e9391d4111e923a9b841376110d04c9 (patch) | |
tree | 5590b3f9b97cf896f26bb641a474908fd20d873f /activerecord/lib/active_record/associations/builder/association.rb | |
parent | fd3211ef677efe9531f38db58919a8c90d65892a (diff) | |
download | rails-336ff8a97e9391d4111e923a9b841376110d04c9.tar.gz rails-336ff8a97e9391d4111e923a9b841376110d04c9.tar.bz2 rails-336ff8a97e9391d4111e923a9b841376110d04c9.zip |
has_many/has_one, :dependent => :restrict, deprecation added.
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index 6e2e5f9de0..54e51b7f44 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -51,5 +51,19 @@ module ActiveRecord::Associations::Builder association(name).writer(value) end end - end + + def dependent_restrict_raises? + ActiveRecord::Base.dependent_restrict_raises == true + end + + def dependent_restrict_deprecation_warning + if dependent_restrict_raises? + msg = "In the next release, `:dependent => :restrict` will not raise a `DeleteRestrictionError`."\ + "Instead, it will add an error on the model. To fix this warning, make sure your code" \ + "isn't relying on a `DeleteRestrictionError` and then add" \ + "`config.active_record.dependent_restrict_raises = false` to your application config." + ActiveSupport::Deprecation.warn msg + end + end + end end |