# 3 simple design questions

**URL:** <https://www.ruby-forum.com/t/3-simple-design-questions/128910>\
**Category:** Rails\
**Created:** [February 12, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/3-simple-design-questions/128910 "2008-02-12T16:27:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gianluca\_t](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d78d45/32.png) [@gianluca\_t](https://www.ruby-forum.com/u/gianluca_t)\
**Post date:** [February 12, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/3-simple-design-questions/128910/1 "2008-02-12T16:27:58Z")

</div>

Hi to all,

I’ve 3 simple (I hope) questions about rails application design:

1. I’m developing a RoR application with some tables, every table has a  
boolean column (is\_active), this column/property determines if the  
object is active or not. My question is “what is the best practice to  
implement this kind of problem ?”:

1.1 - Have boolean is\_active on each table with one base class ? (but  
without STI because every class/table have separated content…)  
1.2 - Have an interface “Activable” on a separate table with a single  
boolean column is\_active then in every table create an active object  
through activable interface ?  
1.3 - Other solutions ?

1. On the same application all the tables/objects belongs to customer  
(multi site app) my question is "is it correct to propagate the  
customer\_id foreign key to all the tables or is it better to have a  
“customerable” interface and link all the objects with has\_one :customer  
through customerable ?

2. Last question: is it a good practice writing modular applications in  
which each one works only with a specialized database and handles linked  
restful resources from other applications ?  
Ex. News application handles only the news database and news  
objects, security application handles only the security database and  
security objects (in this scenario is it possible  
to have map.resources news, :as\_one =\> security where security  
objects don’t belong to the same application ?)

Many thanks in advance and happy programming with Ruby On Rails !

---

<div class="post-metadata">

**Author:** ![gianluca\_t](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d78d45/32.png) [@gianluca\_t](https://www.ruby-forum.com/u/gianluca_t)\
**Post date:** [February 12, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/3-simple-design-questions/128910/2 "2008-02-12T20:32:43Z")

</div>

> > “what is the best practice to implement this kind of problem”

1. I really don’t suggest implementing problems.  
This I’d say is a matter of personal preference. You can have a  
boolean on each object, and you can do things like Object.is\_active?

But if you have multiple Object classes, maybe you’ll want an  
activateable polymorphic class. You’ll have to consider which will  
have the most benefits for your situation.

1. What are you doing through customer for again? Unless you ahve many  
crazy relationships just  
ObjectType1 belongs\_to :customer  
ObjectType2 belongs\_to :customer

:customer has\_many :ObjectType1, :ObjectType2, etc

On Feb 12, 9:17 am, Gianluca T.

---

<div class="post-metadata">

**Author:** ![gianluca\_t](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/d78d45/32.png) [@gianluca\_t](https://www.ruby-forum.com/u/gianluca_t)\
**Post date:** [February 13, 2008, 6:44pm UTC](https://www.ruby-forum.com/t/3-simple-design-questions/128910/3 "2008-02-13T18:44:46Z")

</div>

Thanks I choose to stay with the column is\_active and customer\_id in  
every table, after all this is the best way for high speed (no relation  
at all…).

Have a nice day.

> > Hi to all,  
> > 1.2 - Have an interface “Activable” on a separate table with a single  
> > 3. Last question: is it a good practice writing modular applications in

## – Gianluca T. TreNetMediaMaster S.r.l. The Internet Technology Company Telefono +39(049)776196 Fax +39(049)8087806 Visit us @: [http://www.trenet.it](http://www.trenet.it) - [http://www.mediamaster.it](http://www.mediamaster.it) e-mail me @: removed\_email\_address@domain.invalid

Le informazioni trasmesse sono destinate esclusivamente alla persona o  
alla societÃ in indirizzo e sono da intendersi confidenziali e  
riservate.  
Ogni trasmissione, inoltro, diffusione o altro uso di queste  
informazioni a persone o societÃ differenti dal destinatario Ã© proibita.  
Se ricevete questa comunicazione per errore, contattate il mittente e  
cancellate le informazioni da ogni computer.
