summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/routable_actions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/routable_actions.rb')
-rw-r--r--app/controllers/concerns/routable_actions.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb
new file mode 100644
index 00000000000..6f16377a156
--- /dev/null
+++ b/app/controllers/concerns/routable_actions.rb
@@ -0,0 +1,11 @@
+module RoutableActions
+ extend ActiveSupport::Concern
+
+ def ensure_canonical_path(routable, requested_path)
+ return unless request.get?
+
+ if routable.full_path != requested_path
+ redirect_to request.original_url.sub(requested_path, routable.full_path)
+ end
+ end
+end