Module: Proxy::ActionView::UrlHelper

Defined in:
lib/proxy/action_view/url_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/proxy/action_view/url_helper.rb', line 4

def self.included(base)
  base.class_eval { alias_method_chain :url_for, :proxy }
end

Instance Method Details

#url_for_with_proxy(options = {}) ⇒ Object

Adds the default :host option unless already specified

It will not set the :host option if options is not a hash or if the ActionController::UrlWriter.default_url_options[:host] is blank



12
13
14
15
16
17
18
# File 'lib/proxy/action_view/url_helper.rb', line 12

def url_for_with_proxy(options = {})
  if options.is_a?(Hash)
    options[:host] ||= ::ActionController::UrlWriter.default_url_options[:host] unless ::ActionController::UrlWriter.default_url_options[:host].blank?
    options.delete(:original_host)
  end
  url_for_without_proxy(options)
end