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? -- Kevin http://kevin.is-a-geek.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060116/765a0fee/attachment.html
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. Kevin Davis wrote:> 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? > > -- > Kevin > http://kevin.is-a-geek.net > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >
acts_as_versioned http://wiki.rubyonrails.com/rails/pages/ActsAsVersioned -- -- Tom Mornini On Jan 16, 2006, at 11:54 AM, Kevin Davis wrote:> 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? > > -- > Kevin > http://kevin.is-a-geek.net > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060117/34a207d3/attachment.html