更新时间:2023-02-26 10:15:50
Rails 3.0 内置了此功能,您可以从 request.subdomain
访问子域.
Rails 3.0 has this capability built-in, you can access the subdomain from request.subdomain
.
您也可以根据子域进行路由:
You can also route based on the subdomain:
class SupportSubdomain
def self.matches?(request)
request.subdomain == "support"
end
end
Basecamp::Application.routes do
constraints(SupportSubdomain) do
match "/foo/bar", :to => "foo#bar"
end
end
如果您使用的是 2.3,则需要使用诸如 subdomain-fu.
If you're using 2.3, you'll need to use a plugin such as subdomain-fu.