Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !2164

Use `field.name` rather than `field.nested_form.resource_name` for `Field::HasOne` labels

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/edwinwills/has-one-field-name into main Mar 24, 2022
  • Overview 1
  • Commits 3
  • Pipelines 0
  • Changes 2

Created by: edwinwills

If a model has multiple has_one relationships to the same model (e.g. two has_one associations with different scopes), we can't override the field label for the two associations, we can only change the translation for both at the same time, as the translation is based on the associated class name, not the association name.

This change uses the association name as the lookup field and default value for the label for has_one relationships, allowing multiple relations to the same class to have their own translated labels.

This is a potential breaking change for apps that have set a translation label based on the class name, but have a custom-named association (e.g. if a model has the association :external_user pointing to a User class, the translated label would be listed under user and would need to be changed to external_user.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/edwinwills/has-one-field-name