# About user domain

**URL:** <https://www.ruby-forum.com/t/about-user-domain/152751>\
**Category:** Rails\
**Created:** [November 7, 2008, 4:35am UTC](https://www.ruby-forum.com/t/about-user-domain/152751 "2008-11-07T04:35:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [November 7, 2008, 4:35am UTC](https://www.ruby-forum.com/t/about-user-domain/152751/1 "2008-11-07T04:35:57Z")

</div>

I have an application which has the common content sharing and  
customized content for the registered users,the registered user use  
his control panel to make his customized part for the app.When anyone  
browse this registered user’s site using the user’s domain,the site  
has app’s common and customized contents displaying.For example:if a  
registered user’s name is daociyiyou,he will have his site url like:  
[daociyiyou.com](http://daociyiyou.com).  
My question is:different registered users have different domains,but  
these different domains use the same controller and actions to access  
their common and customized contents.How do i manage this? use the  
rails route to deploy? but how to deploy? In addition,do i have to do  
somthing with the server setting?Thank you for your help.

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [November 7, 2008, 8:07am UTC](https://www.ruby-forum.com/t/about-user-domain/152751/2 "2008-11-07T08:07:01Z")

</div>

anyone can tell me the key points about this problem?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [November 10, 2008, 1:59am UTC](https://www.ruby-forum.com/t/about-user-domain/152751/3 "2008-11-10T01:59:07Z")

</div>

anyone can tell me the key points about this problem?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [November 11, 2008, 2:55am UTC](https://www.ruby-forum.com/t/about-user-domain/152751/4 "2008-11-11T02:55:40Z")

</div>

Thank you ! This should be the application internal implement and make  
me relax much more.But i have another question,how do i generate urls  
for diffrent domains and make them to be mapped to the same controller  
and action?  
Use the route setting and do something with the server?I ever used the  
route ,but not for this problem.Can i manage it like this?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [November 10, 2008, 11:54am UTC](https://www.ruby-forum.com/t/about-user-domain/152751/5 "2008-11-10T11:54:30Z")

</div>

> My question is:different registered users have different domains,but  
> these different domains use the same controller and actions to access  
> their common and customized contents.How do i manage this? use the  
> rails route to deploy? but how to deploy? In addition,do i have to do  
> somthing with the server setting?Thank you for your help.

Use the domain to lookup the account model and base everything off  
that. For example:

class ApplicationController \< ActionController::Base  
before\_filter :set\_application

private  
def set\_application  
@application = Application.find\_by\_domain(request.domain)  
end  
end

class ArticlesController \< ApplicationController  
def index  
@articles = @application.articles  
end

def show  
@article = @application.articles.find(params[:id])  
end  
end
