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

Model plurality inconsistent when defining custom human readable names and errors in locale files #26544

Closed
johnwhelchel opened this issue Sep 19, 2016 · 3 comments

Comments

@johnwhelchel
Copy link

Steps to reproduce

Create model choice_question_option with field called text. We want to customize the human readable name and error message when :taken validation (uniqueness) fails. Setup a simple validation for uniqueness on text. Try to add a new model with the same text as an old model. Examine error messages produced on the errors field.

Expected behavior

Overriding text in a YAML should only require the singular table name in both cases.

According to both Rails docs, singular model names should be used (this is also mirrored in comments in the ActiveRecord code). That would mean a yaml file like:

en:
  activerecord:
    attributes:
      choice_question_option:
        text: "Super question"
    errors:
      models:
        choice_question_option:
          attributes:
            text:
              taken: "is already used by another question."

Actual behavior

However, this does not work. The plurality is inconsistent. I found only the following function as expected:

en:
  activerecord:
    attributes:
      choice_question_options: # note plural model name here
        text: "Super question"
    errors:
      models:
        choice_question_option:
          attributes:
            text:
              taken: "is already used by another question."

System configuration

Rails version:
5.0.0.1
Ruby version:
2.3.1p112

@maclover7
Copy link
Contributor

Investigating.

@maclover7
Copy link
Contributor

Hi @johnwhelchel! Using this reproduction script, I am not able to reproduce the error you are seeing. Please feel free to edit/modify my script as you see fit (or use a base executable test script template, which are found here, that would demonstrate the problem you are seeing.

@stale stale bot added the stale label Mar 27, 2017
@stale
Copy link

stale bot commented Mar 27, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 5-1-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@stale stale bot closed this as completed Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants