Reputation: 23
I'm a Rails noob and I'm sure this is fairly straightforward but I'm not sure how to do it, so I'm going to ask for help.
Here's my situation. I have a Rails 3 app. The app follows the subdomain as account key pattern like Basecamp does. What I would like to do is redirect to the subdomain using this syntax (let's say the current account is @account
).
redirect_to @account
Currently, (as it should), this redirects to /accounts/(@account.id)
. What I would like to do is make it redirect to (@account.subdomain).myapp.com
. Is there any way to do this?
Upvotes: 2
Views: 859
Reputation: 11228
You can use:
redirect_to "http://#{@account.subdomain}.myapp.com/"
Upvotes: 5