views:

21

answers:

1

Depending on the subdomain I want to call a specific controller.

What I currently do: My page uses the subdomain to identify users like username.site.com. I get the username, look it up in the database and render the appropriate data in the UsernamesController.

the only exception to this is www.site.com or site.com . In that case another controller should be called. I currently do this by detecting the www or '' subdomain in `ApplicationController and then redirecting. Although I feel that a redirect is not in it's place here.

Someone has another approach?

Thanks

+1  A: 

subdomains_routes allows you to define custom routes based on current subdomain.

Simone Carletti