LoginSignup
0
0

More than 5 years have passed since last update.

validationのエラーメッセージでattributesを日本語にできなくてハマった話。

Posted at

モデルの名前を名前空間で区切ってた

class Hoge::Fuga::Mogeみたいな感じ。
テーブル名はhoge_fuga_mogeになってる。

ダメなパターン

ja:
  activerecord:
    attributes:
      hoge_fuga_moge:
        name: 氏名
        tel: 電話番号

日本語が適用されません。(当たり前)

正しいパターン

ja:
  activerecord:
    attributes:
      hoge/fuga/moge:
        name: 氏名
        tel: 電話番号

スラッシュで区切りましょう!

普段、名前空間を分けることがなかったので、ハマりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0