aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorManoj <manoj.kumar@risingsuntech.net>2012-01-31 13:46:07 +0530
committerManoj <manoj.kumar@risingsuntech.net>2012-01-31 14:11:14 +0530
commit23074c81a5e0b1e08e2e6555053678e8d656f484 (patch)
treef61d967aea60bfeaa04699ce318d967c45d16b36 /activerecord/lib/active_record
parent3053f52671164530b811238f86954cb96f6ebc16 (diff)
downloadrails-23074c81a5e0b1e08e2e6555053678e8d656f484.tar.gz
rails-23074c81a5e0b1e08e2e6555053678e8d656f484.tar.bz2
rails-23074c81a5e0b1e08e2e6555053678e8d656f484.zip
suggested fixes for :dependent => :restrict deprecation.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations.rb6
-rw-r--r--activerecord/lib/active_record/associations/builder/association.rb2
-rw-r--r--activerecord/lib/active_record/locale/en.yml2
3 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index b44ab26a73..958821add6 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1097,7 +1097,8 @@ module ActiveRecord
# alongside this object by calling their +destroy+ method. If set to <tt>:delete_all</tt> all associated
# objects are deleted *without* calling their +destroy+ method. If set to <tt>:nullify</tt> all associated
# objects' foreign keys are set to +NULL+ *without* calling their +save+ callbacks. If set to
- # <tt>:restrict</tt> this object cannot be deleted if it has any associated objects.
+ # <tt>:restrict</tt> an error will be added to the object, preventing its deletion, if any associated
+ # objects are present.
#
# If using with the <tt>:through</tt> option, the association on the join model must be
# a +belongs_to+, and the records which get deleted are the join records, rather than
@@ -1250,7 +1251,8 @@ module ActiveRecord
# If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to
# <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method.
# If set to <tt>:nullify</tt>, the associated object's foreign key is set to +NULL+.
- # If set to <tt>:restrict</tt>, this object cannot be deleted if it has any associated object.
+ # If set to <tt>:restrict</tt>, an error will be added to the object, preventing its deletion, if an
+ # associated object is present.
# [:foreign_key]
# Specify the foreign key used for the association. By default this is guessed to be the name
# of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb
index 45d3f37089..ba2fcf5ed7 100644
--- a/activerecord/lib/active_record/associations/builder/association.rb
+++ b/activerecord/lib/active_record/associations/builder/association.rb
@@ -74,7 +74,7 @@ module ActiveRecord::Associations::Builder
if dependent_restrict_raises?
raise ActiveRecord::DeleteRestrictionError.new(name)
else
- errors.add(:base, :restrict_dependent_destroy, :model => name)
+ errors.add(:base, :restrict_dependent_destroy, :model => name.to_s.singularize)
return false
end
end
diff --git a/activerecord/lib/active_record/locale/en.yml b/activerecord/lib/active_record/locale/en.yml
index 88edabfd41..8892f7ef2f 100644
--- a/activerecord/lib/active_record/locale/en.yml
+++ b/activerecord/lib/active_record/locale/en.yml
@@ -10,7 +10,7 @@ en:
messages:
taken: "has already been taken"
record_invalid: "Validation failed: %{errors}"
- restrict_dependent_destroy: "Cannot delete record because dependent %{model} exist"
+ restrict_dependent_destroy: "Cannot delete record because dependent %{model} exists"
# Append your own errors here or at the model/attributes scope.
# You can define own errors for models or model attributes.