Class: ActionDispatch::Routing::RouteSet

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/subdomain/url_for.rb

Instance Method Summary collapse

Instance Method Details

#url_for_with_subdomain(options = nil) ⇒ Object

Rails constructs subdomain-based routes correctly, but sometimes need a kick in the pants when generating a path and the route subdomain doesn’t match the current subdomain



7
8
9
10
11
12
13
# File 'lib/rails/subdomain/url_for.rb', line 7

def url_for_with_subdomain options=nil
  if options.kind_of? Hash and options.has_key? :subdomain and options[:_path_segments] and options[:_path_segments][:subdomain] != options[:subdomain]
    options[:only_path] = false
  end

  url_for_without_subdomain options
end