Commit e6955d74 authored by Stan Hu's avatar Stan Hu

Rename requested_full_path to routable_full_path

This was confusing since we are now passing in the requested_full_path
as path_info.
parent 6e973420
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
module RoutableActions module RoutableActions
extend ActiveSupport::Concern extend ActiveSupport::Concern
def find_routable!(routable_klass, requested_full_path, path_info, extra_authorization_proc: nil) def find_routable!(routable_klass, routable_full_path, path_info, extra_authorization_proc: nil)
routable = routable_klass.find_by_full_path(requested_full_path, follow_redirects: request.get?) routable = routable_klass.find_by_full_path(routable_full_path, follow_redirects: request.get?)
if routable_authorized?(routable, extra_authorization_proc) if routable_authorized?(routable, extra_authorization_proc)
ensure_canonical_path(routable, requested_full_path) ensure_canonical_path(routable, routable_full_path)
routable routable
else else
perform_not_found_actions(routable, not_found_actions, path_info) perform_not_found_actions(routable, not_found_actions, path_info)
...@@ -42,13 +42,13 @@ module RoutableActions ...@@ -42,13 +42,13 @@ module RoutableActions
end end
end end
def ensure_canonical_path(routable, requested_full_path) def ensure_canonical_path(routable, routable_full_path)
return unless request.get? return unless request.get?
canonical_path = routable.full_path canonical_path = routable.full_path
if canonical_path != requested_full_path if canonical_path != routable_full_path
if !request.xhr? && request.format.html? && canonical_path.casecmp(requested_full_path) != 0 if !request.xhr? && request.format.html? && canonical_path.casecmp(routable_full_path) != 0
flash[:notice] = "#{routable.class.to_s.titleize} '#{requested_full_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path." flash[:notice] = "#{routable.class.to_s.titleize} '#{routable_full_path}' was moved to '#{canonical_path}'. Please update any links and bookmarks that may still have the old path."
end end
redirect_to build_canonical_path(routable), status: :moved_permanently redirect_to build_canonical_path(routable), status: :moved_permanently
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment