开发者

Rails redirect_to subdomain of account using simple syntax

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开发者_如何学Python /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?


You can use:

redirect_to "http://#{@account.subdomain}.myapp.com/"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜