Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the keys for association `restrict_dependent_destroy` errors in favor of new key names #20668

Merged

Conversation

@repinel
Copy link
Member

repinel commented Jun 23, 2015

As suggested by #11658 (comment), it deprecates the restrict_dependent_destroy errors keys in favor of better key names.

The :'restrict_dependent_destroy.one' key should be replaced with :'restrict_dependent_destroy.has_one', and :'restrict_dependent_destroy.many' with :'restrict_dependent_destroy.has_many'.

@rafaelfranca Is this what you expected?

Closes #11658

@repinel repinel force-pushed the repinel:rename-restrict-dependent-destroy-i18n-key branch 3 times, most recently from 9911b08 Jun 23, 2015
@repinel
Copy link
Member Author

repinel commented Jul 10, 2015

@rafaelfranca What do you think?

@repinel repinel force-pushed the repinel:rename-restrict-dependent-destroy-i18n-key branch to fd3a8c2 Jul 21, 2015
@repinel
Copy link
Member Author

repinel commented Jul 21, 2015

@rafaelfranca Is this one still valid?

(sorry for the multiples pings)

@rafaelfranca
Copy link
Member

rafaelfranca commented Jul 21, 2015

(sorry for the multiples pings)

No problem at all. I way back in my backlog lately.

assert !firm.errors.empty?

assert_equal 'message for deprecated key', firm.errors[:base].first
assert RestrictedWithErrorFirm.exists?(:name => 'restrict')

This comment has been minimized.

Copy link
@rafaelfranca

rafaelfranca Jul 21, 2015

Member

New hash syntax.

I18n.backend = I18n::Backend::Simple.new
I18n.backend.store_translations :en, activerecord: { errors: { messages: { restrict_dependent_destroy: { many: 'message for deprecated key' } } } }

firm = RestrictedWithErrorFirm.create!(:name => 'restrict')

This comment has been minimized.

Copy link
@rafaelfranca

rafaelfranca Jul 21, 2015

Member

New hash syntax

I18n.backend.store_translations :en, activerecord: { errors: { messages: { restrict_dependent_destroy: { many: 'message for deprecated key' } } } }

firm = RestrictedWithErrorFirm.create!(:name => 'restrict')
firm.companies.create(:name => 'child')

This comment has been minimized.

Copy link
@rafaelfranca

rafaelfranca Jul 21, 2015

Member

New hash syntax


assert_equal 'message for deprecated key', firm.errors[:base].first
assert RestrictedWithErrorFirm.exists?(:name => 'restrict')
assert firm.companies.exists?(:name => 'child')

This comment has been minimized.

Copy link
@rafaelfranca

rafaelfranca Jul 21, 2015

Member

New hash syntax

Previously `has_one` and `has_many` associations were using the
`one` and `many` keys respectively. Both of these keys have special
meaning in I18n (they are considered to be pluralizations) so by
renaming them to `has_one` and `has_many` we make the messages more
explicit and most importantly they don't clash with linguistical
systems that need to validate translation keys (and their
pluralizations).

The `:'restrict_dependent_destroy.one'` key should be replaced with
`:'restrict_dependent_destroy.has_one'`, and
`:'restrict_dependent_destroy.many'` with
`:'restrict_dependent_destroy.has_many'`.

[Roque Pinel & Christopher Dell]
@repinel repinel force-pushed the repinel:rename-restrict-dependent-destroy-i18n-key branch from fd3a8c2 to b184398 Jul 21, 2015
@repinel
Copy link
Member Author

repinel commented Jul 21, 2015

@rafaelfranca I fixed the hash syntax.

rafaelfranca added a commit that referenced this pull request Jul 21, 2015
…roy-i18n-key

Deprecate the keys for association `restrict_dependent_destroy` errors in favor of new key names
@rafaelfranca rafaelfranca merged commit 36ea89a into rails:master Jul 21, 2015
@repinel
Copy link
Member Author

repinel commented Jul 21, 2015

💚 💛 💙

@repinel repinel deleted the repinel:rename-restrict-dependent-destroy-i18n-key branch Jul 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.