Add a controller method `redirect_back`

Akinori MUSHA vor 9 Jahren
Ursprung
Commit
00dcc88830
1 geänderte Dateien mit 6 neuen Zeilen und 0 gelöschten Zeilen
  1. 6 0
      app/controllers/application_controller.rb

+ 6 - 0
app/controllers/application_controller.rb

@@ -6,6 +6,12 @@ class ApplicationController < ActionController::Base
6 6
 
7 7
   helper :all
8 8
 
9
+  def redirect_back(fallback_path, *args)
10
+    redirect_to :back, *args
11
+  rescue ActionController::RedirectBackError
12
+    redirect_to fallback_path, *args
13
+  end
14
+
9 15
   protected
10 16
 
11 17
   def configure_permitted_parameters