ruby on rails - Most code-efficient way to handle data stamped as "final" vs. data that may incur changes -


I have several models whose records and associations can have two states which should be maintained. Last, and Draft.

Here's a little more detail: If the model is "application form" and the user submits the final application form, then I need to be able to store and enable that last application form.

If, at a later date, the user wants to modify the application form, then they need to edit a draft copy of that final record, as long as it submits a new final version. Do not. That is, he can not edit the last application form until he checks the "last" box, on which the draft will become the new final version.

The grip is that both the last and draft associations should be stored with their respective records that is, their respective records (for example, ) Should be stored in a manner that is recoverable from final and draft versions without interfering with 'last' contact and a 'draft' contact.

Currently, I can think of two ways to solve this problem:

  • Use only actuators and audits with final records. Whenever I need them, inquire for the final. (There is a thorn of ACTAodit which also tracks associations).
  • Use two parallel data table sets: The one that holds the draft, and the other that only holds the final copies.

I think keeping the final and draft in the same table can be repeated for the purpose of those tables, and it can be difficult to follow the structure.

Do you know any other schema or strategy that will handle the problem more beautifully? Or will it reduce code complexity?

There is a similar question that has expired using the second option given above:

Bernie

< P>

The catch is that there are associations in both final and draft which should be kept in sync

How can the last version change, ever? The last version should be immutable

Do you mean that someone else can draft a draft, while some other document can make a draft?

If it is, then source control is applied. The wiki-view would be useful to merge documents, or there would be a simple 'locking' theory so that two users do not struggle.

To store a version of a document, if you want to disconnect using the file system and use a traditional database, there are two main approaches:

    < Li>

    Flag with a flag for the draft, the last, and the flag for the 'head' - the last version of each of the most recent documents

  1. Three Tables: A table of 'heads', a separate table of drafts and historical end One-third of the table with versions

The advantage of an approach on the other will be the display and distribution if the system is actually bigger.

But if the system is small, then I advocate the first approach - a table - possibly with the cleverness of three 'ideas' to make the version of the more complex three-table approach less painful in 2.0 for.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -