diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-05-19 02:23:05 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-05-19 19:13:27 +0300 |
commit | 49697bc8df613dfe8e88f5f7cd8eae57e26c786f (patch) | |
tree | da5888be64878d8b35d1727dc802d609960fd631 /app/controllers/groups_controller.rb | |
parent | f9785dcec34c4205732871523f95b9743db00965 (diff) |
Refactor to more robust implementation
In order to avoid string manipulation or modify route params (to make them unambiguous for `url_for`), we are accepting a behavior change:
When being redirected to the canonical path for a group, if you requested a group show path starting with `/groups/…` then you’ll now be redirected to the group at root `/…`.
Diffstat (limited to 'app/controllers/groups_controller.rb')
-rw-r--r-- | app/controllers/groups_controller.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 1515173d0ac..965ced4d372 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -169,4 +169,12 @@ class GroupsController < Groups::ApplicationController @notification_setting = current_user.notification_settings_for(group) end end + + def build_canonical_path(group) + return group_path(group) if action_name == 'show' # root group path + + params[:id] = group.to_param + + url_for(params) + end end |