This repository has been archived by the owner on Jul 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #679 from xprazak2/five-deprecations
fix rails 5 deprecations
- Loading branch information
Showing
3 changed files
with
26 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
module Turbolinks | ||
# Corrects the behavior of url_for (and link_to, which uses url_for) with the :back | ||
# option by using the X-XHR-Referer request header instead of the standard Referer | ||
# Corrects the behavior of url_for (and link_to, which uses url_for) with the :back | ||
# option by using the X-XHR-Referer request header instead of the standard Referer | ||
# request header. | ||
module XHRUrlFor | ||
module LegacyXHRUrlFor | ||
def self.included(base) | ||
base.alias_method_chain :url_for, :xhr_referer | ||
end | ||
|
||
def url_for_with_xhr_referer(options = {}) | ||
options = (controller.request.headers["X-XHR-Referer"] || options) if options == :back | ||
url_for_without_xhr_referer options | ||
end | ||
end | ||
|
||
module XHRUrlFor | ||
def url_for(options = {}) | ||
options = (controller.request.headers["X-XHR-Referer"] || options) if options == :back | ||
super options | ||
end | ||
end | ||
end |