about summary refs log tree commit diff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorTakayoshi Nishida <takayoshi.nishida@gmail.com>2017-04-21 23:11:20 +0700
committerEugen <eugen@zeonfederated.com>2017-04-21 18:11:20 +0200
commit5e33ad29d48dcd150d13dfa40151ff21592e728a (patch)
treee6ff7f58c7ae63682d3958665c344784ac340f4e /app/controllers/application_controller.rb
parent27a99b19e842055b869cb5e99f66b4b1e4688780 (diff)
Fix #2195 - Set locale to error pages (#2255)
* Fix #2195 - Set locale to error pages

* Fix #2195 - Cut duplicate process into one method
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e8d7de218..a1b9b985c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -53,21 +53,21 @@ class ApplicationController < ActionController::Base
   def not_found
     respond_to do |format|
       format.any  { head 404 }
-      format.html { render 'errors/404', layout: 'error', status: 404 }
+      format.html { respond_with_error(404) }
     end
   end
 
   def gone
     respond_to do |format|
       format.any  { head 410 }
-      format.html { render 'errors/410', layout: 'error', status: 410 }
+      format.html { respond_with_error(410) }
     end
   end
 
   def unprocessable_entity
     respond_to do |format|
       format.any  { head 422 }
-      format.html { render 'errors/422', layout: 'error', status: 422 }
+      format.html { respond_with_error(422) }
     end
   end
 
@@ -102,4 +102,10 @@ class ApplicationController < ActionController::Base
 
     raw.map { |item| cached_keys_with_value[item.cache_key] || uncached[item.id] }.compact
   end
+
+  def respond_with_error(code)
+    set_locale do
+      render "errors/#{code}", layout: 'error', status: code
+    end
+  end
 end