Rails4.1.1でdate_selectがエラーを吐いた話[undefined method `map' for "translation missing: ja.date.order":String]
date_selectを使おうとしたらエラーを吐いた話です。
バージョン
ruby 2.1.2p95 Rails 4.1.1
エラー文
undefined method `map' for "translation missing: ja.date.order":String
i18Nのja.date.orderが無えぞと
こちらを参考にi18Nの設定
undefined method `-’ for “translation missing: ja, date, order”:String | KumanBlog
すると以下のエラーが
can not load translations from /share/config/locales/ja.yml: #<Psych::SyntaxError: (/share/config/locales/ja.yml): did not find expected node content while parsing a flow node at line 24 column 13>
シンタックスエラーですと
調べてみると書き方が変わっていたみたいです。
以下を参考に書き換え
ruby - Rails 3 yaml errors - Stack Overflow
ja.yml
ja: date: formats: default: "%Y/%m/%d" short: "%m/%d" long: "%Y年%m月%d日(%a)" day_names: [日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日] abbr_day_names: [日, 月, 火, 水, 木, 金, 土] month_names: [~, 1月, 2月, 3月, 4月, 5月, 6月, 7月, 8月, 9月, 10月, 11月, 12月] abbr_month_names: [~, 1月, 2月, 3月, 4月, 5月, 6月, 7月, 8月, 9月, 10月, 11月, 12月] order: - :year - :month - :day time: formats: default: "%Y/%m/%d %H:%M:%S" short: "%y/%m/%d %H:%M" long: "%Y年%m月%d日(%a) %H時%M分%S秒 %Z" am: "午前" pm: "午後"
これで無事date_selectが使えるようになりました。