From a73662f3d8d9ce1a0c54bc0254024c5ecc7cb1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 1 Feb 2012 15:45:11 -0200 Subject: Use human attribute name to show the dependent destroy message --- activerecord/lib/active_record/associations/builder/association.rb | 3 ++- activerecord/lib/active_record/locale/en.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index 0410c3a3c1..2059d8acdf 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -75,7 +75,8 @@ module ActiveRecord::Associations::Builder raise ActiveRecord::DeleteRestrictionError.new(name) else key = association(name).reflection.macro == :has_one ? "one" : "many" - errors.add(:base, :"restrict_dependent_destroy.#{key}", :record => name) + errors.add(:base, :"restrict_dependent_destroy.#{key}", + :record => self.class.human_attribute_name(name).downcase) return false end end diff --git a/activerecord/lib/active_record/locale/en.yml b/activerecord/lib/active_record/locale/en.yml index 896132d566..ad48de2e23 100644 --- a/activerecord/lib/active_record/locale/en.yml +++ b/activerecord/lib/active_record/locale/en.yml @@ -11,7 +11,7 @@ en: taken: "has already been taken" record_invalid: "Validation failed: %{errors}" restrict_dependent_destroy: - one: "Cannot delete record because a dependent %{record} exists" + one: "Cannot delete record because a dependent %{record} exist" many: "Cannot delete record because dependent %{record} exist" # Append your own errors here or at the model/attributes scope. -- cgit v1.2.3