]> cat aescling's git repositories - mastodon.git/commitdiff
Fix #2195 - Set locale to error pages (#2255)
authorTakayoshi Nishida <takayoshi.nishida@gmail.com>
Fri, 21 Apr 2017 16:11:20 +0000 (23:11 +0700)
committerEugen <eugen@zeonfederated.com>
Fri, 21 Apr 2017 16:11:20 +0000 (18:11 +0200)
* Fix #2195 - Set locale to error pages

* Fix #2195 - Cut duplicate process into one method

app/controllers/application_controller.rb

index e8d7de21883288581f1f00ab7bddbb1550f1e478..a1b9b985cc2698c6e7bd3c47cdec13692c34416c 100644 (file)
@@ -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