Skip to content

Conversation

duduribeiro
Copy link

@duduribeiro duduribeiro commented May 31, 2023

Currently the lib tries to render the i18n value of the field even when it is nil. The problem with this is that when you have some i18n of it like the following:
matrimonial_regimes:
community_property: Comunhão universal de bens
partial_property: Comunhão parcial de bens
separate_property: Separação de bens
the lib renders all values on the page as a hash:
{:community_property=>"Comunhão universal de bens", :partial_property=>"Comunhão parcial de bens",
:separate_property=>"Separação de bens"}

image

This happens because the i18n key used on the view "activerecord.attributes.#{field.resource.class.name.underscore}.

will render everything on the top level of my enum translations.

This commit changes the views to not try to render if data is nil.

Currently the lib tries to render the i18n value of the field even
when it is nil. The problem with this is that when you have some
i18n of it like the following:
        matrimonial_regimes:
          community_property: Comunhão universal de bens
          partial_property: Comunhão parcial de bens
          separate_property: Separação de bens
the lib renders all values on the page as a hash:
{:community_property=>"Comunhão universal de bens",
:partial_property=>"Comunhão parcial de bens",
:separate_property=>"Separação de bens"}

This happens because the i18n key used on the view
"activerecord.attributes.#{field.resource.class.name.underscore}.

will render everything on the top level of my enum translations.

This commit changes the views to not try to render if data is nil.
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

Successfully merging this pull request may close these issues.

1 participant