module ActionDispatch::Http::URL

def domain(tld_length = @@tld_length)

a different tld_length, such as 2 to catch rubyonrails.co.uk in "www.rubyonrails.co.uk".
Returns the \domain part of a \host, such as "rubyonrails.org" in "www.rubyonrails.org". You can specify
def domain(tld_length = @@tld_length)
  ActionDispatch::Http::URL.extract_domain(host, tld_length)
end