aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/builder/association.rb3
-rw-r--r--activerecord/lib/active_record/locale/en.yml4
2 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb
index c3fa4a05fd..0410c3a3c1 100644
--- a/activerecord/lib/active_record/associations/builder/association.rb
+++ b/activerecord/lib/active_record/associations/builder/association.rb
@@ -74,7 +74,8 @@ module ActiveRecord::Associations::Builder
if dependent_restrict_raises?
raise ActiveRecord::DeleteRestrictionError.new(name)
else
- errors.add(:base, :restrict_dependent_destroy, :model => name.to_s.singularize)
+ key = association(name).reflection.macro == :has_one ? "one" : "many"
+ errors.add(:base, :"restrict_dependent_destroy.#{key}", :record => name)
return false
end
end
diff --git a/activerecord/lib/active_record/locale/en.yml b/activerecord/lib/active_record/locale/en.yml
index 8892f7ef2f..896132d566 100644
--- a/activerecord/lib/active_record/locale/en.yml
+++ b/activerecord/lib/active_record/locale/en.yml
@@ -10,7 +10,9 @@ en:
messages:
taken: "has already been taken"
record_invalid: "Validation failed: %{errors}"
- restrict_dependent_destroy: "Cannot delete record because dependent %{model} exists"
+ restrict_dependent_destroy:
+ one: "Cannot delete record because a dependent %{record} exists"
+ many: "Cannot delete record because dependent %{record} exist"
# Append your own errors here or at the model/attributes scope.
# You can define own errors for models or model attributes.