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

Return message if attribute has .base suffix #20962

Conversation

adam12
Copy link

@adam12 adam12 commented Jul 21, 2015

Error messages created by the saving of associated models (via
autosave: true on association or other) are namespaced and separated
by a period. Any error messages set by the associated model on their
base attribute should be returned in their entirety, and not prefixed
with a humanized representation of the attribute name.

Possible fix for #19863

Error messages created by the saving of associated models (via
`autosave: true` on association or other) are namespaced and separated
by a period. Any error messages set by the associated model on their
base attribute should be returned in their entirety, and not prefixed
with a humanized representation of the attribute name.

Possible fix for rails#19863
@danielolivaresd
Copy link

danielolivaresd commented Jun 27, 2019

@adam12 Why was this closed and never merged? I'm still facing the issue mentioned in #19863, so I monkey patched ActiveModel::Errors#full_message almost exactly as how this PR intended, which did the trick for me.

A workaround if we don't want something like "Child Oops, invalid", but "Oops, invalid" is to do something like the following:

#en.yml
activerecord:
  attributes:
    parent/child:
          base: ''
  errors:
    models:
      child:
        attributes:
          base:
            custom_invalid: Oops, invalid

, but I don't see why this PR wouldn't be helpful. Am I missing something?

@adam12
Copy link
Author

adam12 commented Jun 27, 2019

@K1N5L4Y3R

This PR functioned fine (AFAIK). It was closed while I was grooming open PRs and closing any that looked stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants