i18nのロケール設定が突然英語(en)以外効かなくなりました。
何がキッカケかわからないのですが、
http://sampleurl.com/ja
としてサイトを開いても日本語表示されず、リンクも全部enへのものしか
出てこないという状態となっています。
言語ファイルも
/config/locales
devise.en.yml devise.ja.yml en.yml ja.yml
のように用意してあり、現在はen.ymlしか効いていない状況です。
Rubyは2.3でRailsは4.2.3です。Rubyは2.3に最近上げたばかりです。
どこをチェックすべきなのか検討つかないのですが、
RouteファイルとApplicationControllerは以下のようになっています。
特に以前動作していた時から変更は加えていないです。
何が問題なのでしょうか?ここをチェックせよという箇所ありますでしょうか?
どうかよろしくお願いします。
ruby
1Rails.application.routes.draw do 2 3 # The priority is based upon order of creation: first created -> highest priority. 4 # See how all your routes lay out with "rake routes". 5 6 # You can have the root of your site routed with "root" 7 # root 'welcome#index' 8 9 10devise_for :users, skip: [:session, :password, :registration], controllers: { omniauth_callbacks: "users/omniauth_callbacks" } 11 12 13 # Locale Information 14scope "(:locale)", locale: /en|ja/ do 15 get '/' => 'frontpage#index' 16 get 'restaurant/' => 'restaurant#index' 17 get 'restaurant/:id' => 'restaurant#show' 18 get 'menu/' => 'menu#index' 19 get 'menu/:id' => 'menu#show' 20 get 'area/' => 'area#index' 21 get 'area/:id' => 'area#show' 22 23 resources :reviews 24 25 devise_for :users, skip: [:omniauth_callbacks] 26 27end
ruby
1class ApplicationController < ActionController::Base 2 # Prevent CSRF attacks by raising an exception. 3 # For APIs, you may want to use :null_session instead. 4 protect_from_forgery with: :exception 5 6 before_action :set_locale, :configure_permitted_parameters, if: :devise_controller? 7 8 9 def set_locale 10 I18n.locale = params[:locale] || I18n.default_locale 11 end 12 13 def default_url_options(options = {}) 14 { locale: I18n.locale }.merge options 15 end 16 17 private 18 def configure_permitted_parameters 19 devise_parameter_sanitizer.for(:sign_up)<<:name 20 devise_parameter_sanitizer.for(:account_update) << :name 21 end 22
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/16 03:37
2016/07/16 07:43
2016/07/18 03:49