lundi 5 septembre 2016

are there any design patterns to deal with the two models and same database table?

i'm blocked at this level, i have a model as shown in the picture, i want to use one single database table for both validated and notValidated documents, since the same document can have an association with both of the models.class diagram neither STI nor polymorphic associations are solution to this issue. so the question is how can i manage in rails, to create two models but one database table for it, is there a design pattern that goes this way ?.

For example :

document { id: 1, added_by: user1}
document_not_validated { duration_estimated: 12}
document_validated { duration_after_validation: 10, added_by: super_user}.

So all these data could be in one line in the DB table, but i need different models (setting the table name is not the solution i look for neither)

thanks

Aucun commentaire:

Enregistrer un commentaire