Railsのi18n
Railsアプリに対してRubocopをかけたところ、以下の警告が出た。
app/controllers/todos_controller.rb:45:60: C: Rails/I18nLocaleTexts: Move locale texts to the locale files in the config/locales directory. format.html { redirect_to todo_url(@todo), notice: 'Todo was successfully updated.' }
以下のようなYAMLファイルをconfig/locales/en.yml
として作って...
en: todos: create: success: 'Todo was successfully created.' update: success: 'Todo was successfully updated.' destroy: success: 'Todo was successfully destroy.'
controllerにて、以下のように記述する。
format.html { redirect_to todo_url(@todo), notice: t('.success') }