6

Well, I've seen some plugins to create a versions table to keep track of modifications on specific models, but cant do easily like quora shows

Changing a topic photo on quora

What I have so far is a table like that:

  • id
  • item_type: especifies what model revision refers: "Topic"
  • item_id
  • event: if it was: "edited, added, reverted, removed"
  • who: who triggered the event
  • column: What column in "Topic" the value has changed. "topic.photo_url"
  • new: new value: "http://s3.amazonaws.../pic.png"
  • old old value: ""http://s3.amazonaws.../oldpic.png"
  • revision_rel: points to the past revision
  • timestamp

enter image description here

Someone could give me some help and guidelines with this design? Im worried about performance, wrong columns, missing columns, etc

id  | item_type | item_id |  event  |    who    | column |   new      |    old     | revision_rel |  date
________________________________________________________________________________________________________
1   |   Topic   |    2    |  edit   |   Luccas  |  photo | pic.png    | oldpic.png |    null      |  m:d:y
2   |   Topic   |    2    |  revert |   Chris   |  photo | oldpic.png | pic.png    |      1       |  m:d:y
1
  • You probably do not need this anymore... but you do might not need to store the old and the new value if you record all the events (create, edit, destroy). The old value of version 2 is the new value of version 1. Depends on your usecase.
    – Pascal
    May 9, 2014 at 14:28

1 Answer 1

1

There are some gems available that already do what you are looking for. Have you looked into:

Take a looks at existing gems: https://www.ruby-toolbox.com/categories/Active_Record_Versioning

I am using audited (previously acts_as_audited) for something very similar: https://github.com/collectiveidea/audited

1
  • I will edit my question later to say that this plugins doesnt do what I need. I want versioning by column, and not the entire row. I will describe this better later and how im implementing. But thanks for the answer.
    – Luccas
    Jun 27, 2012 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.