Skip to content


Subversion checkout URL

You can clone with
Download ZIP


fix :restrict_with_error message #10787

wants to merge 1 commit into from

6 participants


Suppose User has_many :posts, klass on this context is Post, not User.
We should call human_attribute_name with the owner.


Do we have any test case related to this? If not, I'd recommend adding one. Thanks.


@kuboon ping, did you have time to add the test-case?


It's been three months since we last heard from you. I'm closing this but please report back if you are still interested in this change.

@senny senny closed this
@kuboon kuboon deleted the kuboon:patch-1 branch

I'll retry with proper test cases soon.


I found the same problem. It seems others are facing this too,

I can confirm that @kuboon solution fixes the problem.

As a workaround one can use:

      entity: # Should be the parent class when bug is fixed
        entities: 'entidades'

Probably must be fixed in has_one_association.rb too.


Thank you @guigs.

It's difficult for me to add test cases. I hope anyone to write them.

@kuboon kuboon restored the kuboon:patch-1 branch

I've just saw that the issue still happens in Rails 4.2.3

@senny senny reopened this

@kuboon @leonardofaria could you add a test-case to this PR to prevent against further regressions?


@senny I open a PR #21581 with the test cases for both has_many and has_one associations.

@senny senny closed this in #21581
@kuboon kuboon deleted the kuboon:patch-1 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 29, 2013
  1. @kuboon

    Update has_many_association.rb

    kuboon authored
This page is out of date. Refresh to see the latest.
2  activerecord/lib/active_record/associations/has_many_association.rb
@@ -14,7 +14,7 @@ def handle_dependency
when :restrict_with_error
unless empty?
- record = klass.human_attribute_name(
+ record = owner.class.human_attribute_name(
owner.errors.add(:base, :"restrict_dependent_destroy.many", record: record)
Something went wrong with that request. Please try again.