This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Josh Adams
committed
Nov 23, 2008
1 parent
5f168b7
commit 1203be9
Showing
3 changed files
with
47 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module UrlWriterRetardaseInhibitor | ||
module ActionController | ||
def self.included(ac) | ||
ac.send(:include, InstanceMethods) | ||
end | ||
|
||
module InstanceMethods | ||
def inhibit_retardase | ||
begin | ||
request = self.request | ||
::ActionController::UrlWriter.module_eval do | ||
@old_default_url_options = default_url_options.clone | ||
default_url_options[:host] = request.host | ||
default_url_options[:port] = request.port unless request.port == 80 | ||
protocol = /(.*):\/\//.match(request.protocol)[1] if request.protocol.ends_with?("://") | ||
default_url_options[:protocol] = protocol | ||
end | ||
yield | ||
ensure | ||
::ActionController::UrlWriter.module_eval do | ||
default_url_options[:host] = @old_default_url_options[:host] | ||
default_url_options[:port] = @old_default_url_options[:port] | ||
default_url_options[:protocol] = @old_default_url_options[:protocol] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
module ActionMailer | ||
def self.included(am) | ||
am.send(:include, ::ActionController::UrlWriter) | ||
::ActionController::UrlWriter.module_eval do | ||
default_url_options[:host] = 'localhost' | ||
default_url_options[:port] = 3000 | ||
default_url_options[:protocol] = 'http' | ||
end | ||
end | ||
end | ||
end | ||
|
||
ActionController::Base.send(:include, UrlWriterRetardaseInhibitor::ActionController) | ||
ActionMailer::Base.send(:include, UrlWriterRetardaseInhibitor::ActionMailer) |