MongoDBを用いたデータ作成の際に発生する translation エラーの対処方法

エラー内容

translation missing: ja.mongoid.errors.messages.message_title: translation missing: ja.mongoid.errors.messages.invalid_value.message 
translation missing: ja.mongoid.errors.messages.summary_title: translation missing: ja.mongoid.errors.messages.invalid_value.summary 
translation missing: ja.mongoid.errors.messages.resolution_title: translation missing: ja.mongoid.errors.messages.invalid_value.resolution

開発環境

CLI
$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

$ bundle exec rails -v
Rails 5.1.4

$ mongo --version
MongoDB shell version v3.6.3
git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
    distmod: rhel70
    distarch: x86_64
    target_arch: x86_64

Gemfile
gem 'mongoid', '~> 6.1.0'

対処方法

config/application.rb
:
require 'i18n/backend/fallbacks'  # 追加
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)  # 追加
:
module MyApp
  class Application < Rails::Application
    :  
    config.i18n.fallbacks = { 'ja' => 'en' }  # 追加
CLI
$ bundle exec rake unicorn:restart RAILS_ENV=development # 再起動

参考記事

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.