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

Incorrect human_attribute_name in case of single table inheritance (STI) #200

Open
kalsan opened this issue Jun 13, 2023 · 1 comment
Open

Comments

@kalsan
Copy link

kalsan commented Jun 13, 2023

Hi!

The following is a bug report. When calling .human_attribute_name(...) on an STI child class in Rails, gettext_i18n_rails looks up the wrong constant. Here's an example:

class Parent < ApplicationRecord; end
class Child < Parent; end

Assuming that Parent has a field :foo which it shares with Child via STI. Translations are (app.po):

msgid "Parent|Foo"
msgstr "Parent's Foo"

msgid "Child|Foo"
msgstr "Child's Foo"

Expected:

Parent.human_attribute_name(:foo) # Parent's foo
Child.human_attribute_name(:foo) # Child's foo

However, gettext_i18n_rails returns:

Parent.human_attribute_name(:foo) # Parent's foo
Child.human_attribute_name(:foo) # Parent's foo --> WRONG

Best,
Kalsan

@grosser
Copy link
Owner

grosser commented Jun 17, 2023

yeah kinda bad ... PR welcome, ideally this would be a fallback from Child|foo to Parent|foo to not break existing behavior, or an opt-in

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

No branches or pull requests

2 participants