开发者

RoR: making a version control function in side my application?

开发者 https://www.devze.com 2023-02-08 18:09 出处:网络
What would be the rails way of implementing version control in my record management application? My system allows users to manage Records and i want to allow them to view historical versions of a开发

What would be the rails way of implementing version control in my record management application?

My system allows users to manage Records and i want to allow them to view historical versions of a开发者_开发技巧 Record. i know instead of updating a Record I will now create a new instance of the Record and related models every time a user "updates" a record(each Record has_many Categories and Advantages). how would i ensure that different versions of the Record are all linked together (i.e the new updated record created to be associated as the new version of record A, so when i click "show me a list of all versions of record A").

this is all theoretical thinking as i am yet to start coding, if i missed anything which i should also consider please let me know.

Thank You


create a new instance of the record every-time a user updates it, have a secondary ID as you mentioned to group all different versions of the same record together and then run a check in the controller (using some sort of hidden value) to see if you want to save over the record or create a new one.

You can then retrive the latest version of each record by finding the most recently updated/created record with a unique secondary_id.


A good starting point may be the vestal versions gem, that keeps an history of modified records


Here are 2 of my insights:

1st simple one :

You save a record with a higher id , when you read it you take the higher id. If you want to know the past do not filter on ids.

2nd (parts from SAP) :

Your record has 2 supplemental fields , that is startTime, stopTime. Thoses are the time the record start entering in action and stops being in action. Inserting a new record , you update the stopTime of the last one, put now as the startTime of the new one, and the end of the world for the stopTime of the new one

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号