This project is archived and is in readonly mode.

#5430 ✓wontfix
Jakub Suder

defining subdomain constraints in router with various TLD lengths

Reported by Jakub Suder | August 23rd, 2010 @ 11:33 AM | in 3.0.2

In the new router, it's possible to define a constraint on the subdomain field, like this:

constraints(:subdomain => 'api') do ... end

However, the subdomain method in request takes an argument that says how long the TLD domain is. Default is 1, so if you have a site like, it works correctly, but for other sites (, localhost) you need to call request.subdomain(2) or request.subdomain(0) respectively.

The problem is that while it's possible to do that in a controller method, it's not possible in the router, which makes the constraints(:subdomain) useless in most cases (unless you use a custom class for constraints). This could be solved by changing the request.subdomain() method so that it takes the TLD length from some kind of global setting which can be set in somewhere in config/ directory.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket