エラーメッセージを日本語化しようと思っているのですが、うまくいきません。
入力内容にエラーがあります
Imageを入力してください
Nameを入力してください
Genderを入力してください
Countryを入力してください
Jobを入力してください
Faceを入力してください
Contentを入力してください
このようになってしまいます。
きっと「ja.yml」の書き方の知識がほとんどないせいだと思いますが、
調べても調べても正解を導き出せません。
config/application.rb↓
require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Myapp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 config.i18n.default_locale = :ja config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml').to_s] # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading # the framework and any gems in your application. end end
posts/new.html.erb↓
<%= form_tag("/posts/create", {multipart: true}) do %> <% if @post.errors.any? %> <strong style="color:red">入力内容にエラーがあります</strong> <ul> <% @post.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> <% end %> <div>画像:</div> <input type="file" name="image" class="img-up"> <br><br> <div>名前:</div> <input type="text" name="name"> <br><br> <div>性別:</div> <input type="text" name="gender"> <br><br> <div>国籍:</div> <input type="text" name="country"> <br><br> <div>職業:</div> <input type="text" name="job"> <br><br> <div>顔:</div> <input type="text" name="face"> <br><br> <div>説明:</div> <textarea name="content"></textarea> <br><br> <input class="submit-btn" type="submit" value="投稿"> <% end %>
ja.yml↓
ja: activerecord: models: post: attributes: post: image: 画像 name: 名前 gender: 性別 country: 国籍 job: 職業 face: 顔 content: 説明
どなたか正しい記述の仕方を教えてください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2019/06/24 16:54
2019/06/25 00:09
2019/06/25 00:12
退会済みユーザー
2019/06/25 01:09
2019/06/25 01:19 編集
2019/06/25 01:31 編集
退会済みユーザー
2019/06/25 01:46