I've been searching around trying to find out if there is some way to attach something to an ActiveRecord class such that every time an update is called, a record of that update (which fields, when) is created. I think it would be useful for syncing information with external services I think. Questions: If there is a wealth of knowledge on this, what search terms will lead me in the right direction? If there isn't something like this in rails, do people have thoughts on the best implementation approach? Would RoR users be able to use such a service if I were to get my hands dirty and write it up?
on 2006-01-17 01:27
on 2006-01-17 03:34
acts_as_versioned http://wiki.rubyonrails.com/rails/pages/ActsAsVersioned -- -- Tom Mornini
on 2006-01-21 15:40
to "hook into" rails, i.e. to specify code to be run everytime (for example) an object is saved, use callbacks. http://api.rubyonrails.com/classes/ActiveRecord/Ca... The code to do what you want manually would be a simple matter of writing a method to do it, and registering your method with a callback. The "updates" table would probably be a seperate model mapped to a seperate table, and your main model would create and save a new one when it itself was saved. To do it automatically (by declaring the model "acts_as_change_logging," to use an unimaginative example) would be more work, but certainly doable.