Rails 3.x TLD 长度 [英] Rails 3.x TLD length
问题描述
Rails 的配置中是否有一些地方可以让我将 TLD 长度全局设置为 2(以 co.uk 为例),以便 request.domain 和 request.subdomain 无需传递选项即可正确解析?
Is there some where in Rails's configuration where I can globally set the TLD length to 2 (co.uk as an example) so request.domain and request.subdomain parse correctly without having to pass options?
也就是说,request.domain(2),默认情况下,Rails 似乎默认设置为 1,能够全局更改它是有意义的,但是,在文档中找不到任何内容.
That is, request.domain(2), by default Rails seems to be set to 1 by default and it makes sense to be able to change this globally, however, haven't been able to find anything in the documentation.
是否存在这样的配置选项?
Does such a configuration option exist?
推荐答案
Rails 3.0.9 及以下,没有这样的配置,因为 domain
的来源是:
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
来源:http://apidock.com/rails/v3.0.9/ActionDispatch/Http/URL/domain
这篇关于Rails 3.x TLD 长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!