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

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

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

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

Q&A

解決済

1回答

2430閲覧

RailsのDeviseの日本語化で困っています

sunagakannta

総合スコア29

Ruby on Rails

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

0グッド

0クリップ

投稿2016/12/10 07:00

###前提・実現したいこと
現在Railsの勉強中で、Deviseの日本語化に挑戦しています。
ブログ等を見ながらやっています。

###発生している問題・エラーメッセージ
サーバーを立ち上げようとすると、エラーが発生します

多くのブログには、 config.i18n.default_locale = :ja
これを、config/application.rbに追加しろとあるのですが、
これを書き込むと、ターミナルでエラーが発生します。

エラーメッセージ rails s /Users/kanta/shout/config/application.rb:7:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)

###該当のソースコード

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) config.i18n.default_locale = :ja module Shout class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. end end

###試したこと
書き込む場所が問題だとおもい、色位rなところに書き込んでみました。
config/application.rb
のいろいろな行に追加してみました。

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

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

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

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

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

guest

回答1

0

ベストアンサー

下のような位置に追加すると日本語設定できます。

ruby

1require_relative 'boot' 2 3require 'rails/all' 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 Shout 9 class Application < Rails::Application 10 # Settings in config/environments/* take precedence over those specified here. 11 # Application configuration should go into files in config/initializers 12 # -- all .rb files in that directory are automatically loaded. 13 config.i18n.default_locale = :ja 14 end 15end

投稿2016/12/10 07:12

cameluby

総合スコア891

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

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

sunagakannta

2016/12/10 10:23

解決できました! ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問