質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

716閲覧

新規登録フォームのカラム名が日本語化できません

zoff77

総合スコア19

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2021/01/06 13:42

モーダルでuser新規登録フォームを表示しているのですが、カラムが日本語になりません。
Gemにはgem 'rails-i18n'を入れています。

erb

1<div class="modal-dialog modal-lg modal-dialog-center"> 2 <div class="modal-content"> 3 <div class="modal-header"> 4 <!--モーダルを閉じる✖︎ボタン--> 5 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 6 <span aria-hidden="true">✖︎</span> 7 </button> 8 <h1 class="modal-title">新規登録</h1> 9 </div> 10 <div class="modal-body"> 11 <div class="row"> 12 <div class="col-md-6 col-md-offset-3"> 13 <%= form_with(model: @user, local: true) do |f| %> 14 <%= f.label :name, class: "label-signup" %> 15 <%= f.text_field :name, class: "form-control" %> 16 17 <%= f.label :email, class: "label-signup" %> 18 <%= f.email_field :email, class: "form-control" %> 19 20 <%= f.label :contact, class: "label-signup" %> 21 <%= f.number_field :contact, class: "form-control" %> 22 23 <%= f.label :password, class: "label-signup" %> 24 <%= f.password_field :password, class: "form-control" %> 25 26 <%= f.label :password_confirmation, class: "label-signup" %> 27 <%= f.password_field :password_confirmation, class: "form-control" %> 28 29 <%= f.submit "新規登録", class: "btn btn-primary btn-block btn-signup" %> 30 <% end %> 31 </div> 32 </div> 33 </div> 34 </div> 35</div> 36

rb

1ActiveRecord::Schema.define(version: 2021_01_06_012738) do 2 3 create_table "users", force: :cascade do |t| 4 t.string "name" 5 t.string "email" 6 t.integer "contact" 7 t.datetime "created_at", null: false 8 t.datetime "updated_at", null: false 9 t.string "password_digest" 10 t.index ["email"], name: "index_users_on_email", unique: true 11 end 12 13end 14

yml

1ja: 2 activerecord: 3 models: 4 user: ユーザー 5 attributes: 6 user: 7 id: ID 8 name: 名前 9 email: メールアドレス 10 contact: 契約日数 11 password: パスワード 12 password_confirmation: パスワード再入力 13 created_at: 作成日 14 updated_at: 更新日

rb

1require_relative 'boot' 2require 'rails/all' 3 4# Require the gems listed in Gemfile, including any gems 5# you've limited to :test, :development, or :production. 6Bundler.require(*Rails.groups) 7 8module AccepteApp 9 class Application < Rails::Application 10 # Initialize configuration defaults for originally generated Rails version. 11 config.load_defaults 5.2 12 config.time_zone = 'Asia/Tokyo' 13 config.i18n.default_locale = :ja # デフォルトの言語を日本語に設定します。 14 config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s] 15 # Settings in config/environments/* take precedence over those specified here. 16 # Application configuration can go into files in config/initializers 17 # -- all .rb files in that directory are automatically loaded after loading 18 # the framework and any gems in your application. 19 end 20end 21

お手数おかけしますが、解決策を教えて下さい。
宜しくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

登録機能先に実装したら日本語化ができました

投稿2021/01/08 01:56

zoff77

総合スコア19

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問