|Flinn Mueller on 15 Feb 2007 03:10:56 -0000|
On Feb 14, 2007, at 6:29 PM, Mike Zornek wrote:
This is really a syntax question as I'm not sure how to override a method
module ActiveRecord module Acts module Versioned module ClassMethods def acts_as_paranoid_versioned acts_as_paranoid acts_as_versioned
# protect the versioned model self.versioned_class.class_eval do def self.delete_all(conditions = nil); return; end end end end end end end
Then instead of both: acts_as_paranoid acts_as_versioned
Add this in your class: acts_as_paranoid_versioned
The ruby code is here:
Clear old versions only runs after_save, and it's only to prune versions in excess of the limit you set. The reason the old versions get deleted is because they are :dependent => :delete_all to the original model and get zapped before_destroy. So the solution is to override versioned_class.delete_all.
With this setup, the versioned record doesn't pick up deleted_at. My guess is (I haven't tested it) if you wanted to revive the record, it would be easier to revert to the record without deleted_at than revert and clear deleted_at so the record is alive again. Ymmv.
To unsubscribe or change your settings, visit: