Rails 3.x TLD length

。_饼干妹妹 提交于 2019-12-01 03:44:43
Jonas Elfström

For Rails 3.0.9 and below, there's no such configuration since the source of domain is:

# File actionpack/lib/action_dispatch/http/url.rb, line 78
def domain(tld_length = 1)
  return nil unless named_host?(host)

  host.split('.').last(1 + tld_length).join('.')
end

Source: http://apidock.com/rails/v3.0.9/ActionDispatch/Http/URL/domain

In your config/environments/production.rb file add this line:

config.action_dispatch.tld_length = 2

config.action_dispatch.tld_length sets the TLD (top-level domain) length for the application. Defaults to 1.

http://guides.rubyonrails.org/configuring.html

In Rails 3.1 you can set:

ActionDispatch::Http::URL.tld_length = 2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!