Module: SubdomainRoutes::UrlWriter

Includes:
RewriteSubdomainOptions
Defined in:
lib/subdomain_routes/url_writer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RewriteSubdomainOptions

#rewrite_subdomain_options, #subdomain_procs

Class Method Details

.included(base) ⇒ Object



50
51
52
# File 'lib/subdomain_routes/url_writer.rb', line 50

def self.included(base)
  base.alias_method_chain :url_for, :subdomains
end

Instance Method Details

#url_for_with_subdomains(options) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/subdomain_routes/url_writer.rb', line 54

def url_for_with_subdomains(options)
  host     = options[:host]     || default_url_options[:host]
  port     = options[:port]     || default_url_options[:port]
  protocol = options[:protocol] || default_url_options[:protocol]
  if options[:subdomains] && host.blank?
    raise HostNotSupplied, "Missing host to link to! Please provide :host parameter or set default_url_options[:host]"
  end
  rewrite_subdomain_options(options, host, port, protocol)
  url_for_without_subdomains(options)
end