Tarscher
Tarscher

Reputation: 1933

avoiding redirect

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

Upvotes: 0

Views: 59

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176372

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

Upvotes: 1

Related Questions