diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-01 11:07:05 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-01 11:07:05 -0800 |
commit | 33d8b62c527b16851db7d7ea79f1269db325d1aa (patch) | |
tree | 7debae34d185fa9beb3780af391402f993853771 /activerecord/lib | |
parent | 403cce77f19bc6c2a3d8acaf547991078a540eaf (diff) | |
parent | e778e22812893c5ac09634ace83a4af168d66a3b (diff) | |
download | rails-33d8b62c527b16851db7d7ea79f1269db325d1aa.tar.gz rails-33d8b62c527b16851db7d7ea79f1269db325d1aa.tar.bz2 rails-33d8b62c527b16851db7d7ea79f1269db325d1aa.zip |
Merge pull request #4829 from rafaelfranca/restrict-fix
Use human attribute name to show the dependent destroy message
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/locale/en.yml | 2 |
2 files changed, 3 insertions, 2 deletions
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. |