3 simple design questions

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 !

“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.

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.mediamaster.it
e-mail me @: [email protected]

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.