When I translated the error message into Japanese, there are columns that are not translated into Japanese. user and item could be translated into Japanese without any problem.
ja:
  activerecord:
    attributes:
      user:
        nickname:nickname
        last_name:name(Last name)
        first_name:name(name)
        last_name_kana:Name katakana(Last name)
        first_name_kana:Name katakana(name)
        birthday:Birthday
      item:
        name:Product name
        image:Exhibition image
        introduction:Product description
        category_id:Category
        status_id:Product condition
        postage_id:Shipping charges
        prefecture_id:Shipping area
        days_to_ship_id:Days to ship
        price:Selling price
        
      user_destination:⬅️ I want to translate this into Japanese
        post_code:Postal code
        prefecture_id:Prefectures
        city:Municipality
        address:address
        phone_number:phone number
Try changing user_destination to destination ... Try changing to destinations ...
% bundle exec rspec spec/models/user_destination_spec.rb
..
    20: 
    21:     context 'When new registration does not go well' do
    22:       it 'Postal code is required' do
    23:         @user_destination.post_code = ''
    24:         @user_destination.valid?
 => 25:         binding.pry
    26:         expect(@user_destination.errors.full_messages).to include("Post code can't be blank")
    27:       end
    28: 
    29:       it 'Hyphen is required for zip code' do
    30:         @user_destination.post_code = '1234567'
[1] pry(#<RSpec::ExampleGroups::UserDestination::Nested::Nested_2>)> @user_destination.errors.full_messages
=> ["Please enter the Post code", "Post code is an invalid value"]
[2] pry(#<RSpec::ExampleGroups::UserDestination::Nested::Nested_2>)> exit
FFFFFFFFFFFF
Post code does not become a zip code no matter how many times I try. I arrived at this article and read it carefully. https://qiita.com/okeicalm/items/9638250ddfb361d80a16
activerecord: models: user: user I suddenly noticed when I was looking at the description.
Hmm? What is activerecord? Looking at each model file, the user_destination model is described as ActiveModel. This may be ...
ja:
  activerecord:
    attributes:
      user:
        nickname:nickname
        last_name:name(Last name)
        first_name:name(name)
        last_name_kana:Name katakana(Last name)
        first_name_kana:Name katakana(name)
        birthday:Birthday
      item:
        name:Product name
        image:Exhibition image
        introduction:Product description
        category_id:Category
        status_id:Product condition
        postage_id:Shipping charges
        prefecture_id:Shipping area
        days_to_ship_id:Days to ship
        price:Selling price
  activemodel:⬅️ Described by changing the hierarchy
    attributes:
      user_destination:
        post_code:Postal code
        prefecture_id:Prefectures
        city:Municipality
        address:address
        phone_number:phone number
% bundle exec rspec spec/models/user_destination_spec.rb
..
    20: 
    21:     context 'When new registration does not go well' do
    22:       it 'Postal code is required' do
    23:         @user_destination.post_code = ''
    24:         @user_destination.valid?
 => 25:         binding.pry
    26:         expect(@user_destination.errors.full_messages).to include("Post code can't be blank")
    27:       end
    28: 
    29:       it 'Hyphen is required for zip code' do
    30:         @user_destination.post_code = '1234567'
[1] pry(#<RSpec::ExampleGroups::UserDestination::Nested::Nested_2>)> @user_destination.errors.full_messages
=> ["Please enter your zip code", "Zip code is an invalid value"]
It has been translated into Japanese! As a result, Active Record and Active Model are different types in the first place, so there is no way I can put them in the active record: group.
I learned a lot today.
Recommended Posts