[RUBY] [Rails] Japanese localization of error message when using Form object

Overview

Only the part where the Form object was implemented in the Rails flea market app did not go well in Japanese, so I will describe how to solve it.

Premise

The creation of the ja.yml file is complete. Error messages other than Form objects can be translated into Japanese.

environment

Contents

Even if I write Japanese input in ja.yml, it doesn't become Japanese

config/locales/ja.yml

ja:
    activerecord:
        attributes:
            user:
                nickname:nickname

            item:
                text:text
                image:image
                name:Product name

            card_address:
                postal_code:Postal code
                city:Municipality
                address:address
                phone_number:phone number

It has been corrected and resolved as follows.

ja:
    activerecord:
        attributes:
            user:
                nickname:nickname


            item:
                text:text
                image:image
                name:Product name

    activemodel:
        attributes:
            card_address:
                postal_code:Postal code
                city:Municipality
                address:address
                phone_number:phone number

Cause

Since the forms / card_address file that describes the form object is a file that inherits ʻActiveModel, it seems that it was not reflected in ʻactiverecord: (second line).

Recommended Posts

[Rails] Japanese localization of error message when using Form object
[Note] Error message when using Rails Form object pattern Japanese
[Rails] Japanese localization of validation error message ~ ja.yml ~
[Rails] Japanese localization of error messages
Japanese localization of error messages (rails)
Japanese localization of error messages
Japanese localization of error messages
[Rails] Japanese localization using rails-i18n
Error when using rails capybara
[Ruby on Rails] How to Japaneseize the error message of Form object (ActiveModel)
From Ruby on Rails error message display to Japanese localization
[Rails] About the error when displaying the screen due to the autofocus of the form
[Rails] Let's translate the error message into Japanese
Rails: Japanese localization of validation messages including devise
Introduction of Rspec and Japanese localization of error messages
Error when using SnapKit
Japanese localization of Eclipse
Japaneseization of Rails error messages [devise / Form objects, etc.]
[Rails] When using ajax, be aware of "CSRF measures".
[Rails] Implementation of multi-layer category function using ancestry "Editing form"
[Rails] Implementation of multi-layer category function using ancestry "Creation form"
Be careful of initialization timing when using MessageEncryptor with Rails 5.2 / 6.0
[Japanese localization of gem: devise]
Finally implemented Rails Form object
Detailed tips when using Rails
[Rails] Creation of the second vertical axis and Japanese localization in graph drawing using amCharts4, etc.
[Rails] Sign-up function using devise error number of arguments (given 0, expected 1)
Unknown error in line 1 of pom.xml when using Spring Boot in Eclipse
[Rails] What was the error message?
[Rails] Check the contents of the object
[Rails] Display form error messages asynchronously
[Rails] Validation settings and Japanese localization
When submitting form, no error message is displayed even though validation failed
Japanese localization of CentOS 8 and Japanese keyboard layout
Get the error message using the any? method
[Ruby] Meaning of &. How to avoid the error when the receiver (object) is nil