LoginSignup
8
7

More than 5 years have passed since last update.

I18n.enforce_available_locales とは何か?

Posted at

rake assets:precompile とかすると、以下のメッセージが出る。

[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.

I18n.enforce_available_locales は、という設定はなんだろう? Stack Overflow に詳しい投稿がある。

i18n Gem の 0.6.9 で導入された機能で、有効なロケールをホワイトリスト形式で設定し、それ以外が指定された場合は例外が発生するようになるようだ。この設定を false にすることで、これまで同じ動き(チェックしない)をするようになる。

このバージョンの i18n は、Rails 4(>= 4.0.2) や Rails 3.2(>= 3.2.14) から導入されている。

また、"will default to true in the future" とあるが、Rails 4.0.4 からデフォルトを true として動作するようになったようだ。

これに伴い Rails Guide にも記述がある。

セキュリティ対策にもなるようなので、今後は、デフォルト値である true にしていくのが望ましいのかな。

8
7
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
8
7