# Structure of app that uses subdomains as account keys

**URL:** <https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126>\
**Category:** Rails\
**Created:** [August 18, 2008, 9:14am UTC](https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126 "2008-08-18T09:14:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [August 18, 2008, 9:14am UTC](https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126/1 "2008-08-18T09:14:46Z")

</div>

Hello-

I’ve created a very simple app that uses subdomains as account keys. I  
followed the instructions at:

[http://wiki.rubyonrails.org/rails/pages/HowToUseSubdomainsAsAccountKeys](http://wiki.rubyonrails.org/rails/pages/HowToUseSubdomainsAsAccountKeys)

My question is how should I best structure the ap?. Specifically, I  
have a public-facing website that explains that app and lets people  
sign up ([www.myapp.com](http://www.myapp.com)) and then the private part of the app  
(account\_subdomain.myapp.com). Does it make sense to have these be two  
separate apps or a single app? I like the idea of a single app because  
it makes it easy to share models (my account model, specifically).  
However, the two apps do differ somewhat. For instance, going to the  
root page of each app should render a very different page. I can  
handle that with some conditional logic, if need be. Also, there are  
things that make sense for one app, but not the other. For instance, I  
have an Account resource. Actions like new only make sense on the  
public website, while actions like edit and delete only make sense on  
the private app.

What would the group recommend for structuring this app? Two apps or  
one app with some conditional logic in it?

Thanks in advance.

-Eric

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [August 18, 2008, 11:04pm UTC](https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126/2 "2008-08-18T23:04:48Z")

</div>

Eric M. wrote:

> What would the group recommend for structuring this app? Two apps or  
> one app with some conditional logic in it?
> 
> Thanks in advance.
> 
> -Eric

It sounds like you want one app and then to use layouts to generate the  
differences you want the users to experience…

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [August 19, 2008, 4:39am UTC](https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126/3 "2008-08-19T04:39:12Z")

</div>

On Aug 18, 7:46 pm, emarthinsen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does anyone know of any open-source Rails applications that uses  
> subdomains that I could use as reference material?
> 
> Regards-  
> Eric

Actually, Railscasts just posted a good tutorial on how to customize  
content based on subdomain using the subdomain\_fu plugin. I’d say it’s  
worth checking out.

Jeff

REST with Rails  
Oct 4, 2008, Austin, TX  
[http://www.purpleworkshops.com/workshops/rest-and-web-services](http://www.purpleworkshops.com/workshops/rest-and-web-services)

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [August 19, 2008, 2:47am UTC](https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126/4 "2008-08-19T02:47:28Z")

</div>

Do you mean layouts or views? I’d imagine both as the private version  
of the site would have a fluid layout and the public site a fixed-  
width, but the major differences are in the content. For instance, the  
public homepage ([www.myapp.com](http://www.myapp.com)) would be drastically different than  
the private webpage (account\_subdomain.myapp.com).

Does anyone know of any open-source Rails applications that uses  
subdomains that I could use as reference material?

Regards-  
Eric

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [August 19, 2008, 5:06am UTC](https://www.ruby-forum.com/t/structure-of-app-that-uses-subdomains-as-account-keys/146126/5 "2008-08-19T05:06:05Z")

</div>

That was perfect. Thanks for pointing it out.

-Eric
