Recording updates

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?

acts_as_versioned

http://wiki.rubyonrails.com/rails/pages/ActsAsVersioned


– Tom M.

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/Callbacks.html

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs