Ruby on Rails: how to track changes like StackOverflow implements its change history?

If I were to implement a system identical to the question change history in StackOverflow using Ruby on Rails , what do I need to do for this? I am creating a website that acts like a wiki where user-generated content can be updated by other people. I need to be able to track the history of these changes, but I do not know how to implement this.

Decision:

In short, the way this works is to create an extra table to track changes. Each row of the table has a β€œsnapshot” of the data that existed before the record was changed (or only the data that was changed).

There are a number of Ruby Gems that have already done most of the work. The following is a list of gems associated with the version / version of the story . It seems Paper Trail is currently the most popular stone for this. Ryan Bates recorded RailsCast, giving an overview of using Paper Trail .

+6
ruby-on-rails ruby-on-rails-3 rubygems
source share
2 answers

When a record is edited, you are not deleting the (old) record, you simply add a new record with a new version number. When you want to get an entry to display, you select the number with the highest version number. When you want to get a record to display its change history, you select all of them and sort them by version number.

+3
source share

I know this is old, but anyone who comes across this, you should check out Paper Trail

+1
source share

All Articles