Mike Zornek on 14 Feb 2007 23:30:00 -0000

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] Looking for help overriding clear_old_version in acts_as_versioned

On 2/14/07 2:36 PM, "Flinn Mueller" <theflinnster@gmail.com> wrote:

> On Feb 14, 2007, at 1:58 PM, Mike Zornek wrote:
>> So far it's working fairly well except that when I destroy an
>> Active Record
>> object the acts_as_versioned plugin is deleting all of the old
>> versions.
>> It's using a method called clear_old_version and in the docs it says:
> Mike,
> You might try removing this line in vendor/plugins/acts_as_versioned/
> lib/acts_as_versioned.rb
> :dependent   => :delete_all
> Mine is on line 189 ymmv.
> Afaik acts_as_paranoid overrides destroy so that instead of
> destroying the record, it sets a deleted_at.  Without getting too
> deep my guess is AR is calling the association code:
> before_destroy { |record| #{reflection.class_name}.delete_all(%(#
> {dependent_conditions})) }
> So even if acts_as_paranoid overrides the normal behavior of destroy
> it isn't overriding the before_destroy callback.  That's just a
> guess, please let me know how you make out, I have a project that
> needs to use both of these plugins for the exact same purpose, so I'd
> like to know if that resolves it for you.

Ok thanks for the info (and to the other comments as well).

I'm a little iffy on editing the plugin code itself as I don't want to
hinder future upgrading with hidden warning of "make sure you comment out
this stuff."

What I'd like to do is probably add something to my app that will be
executed after the application loads (which is last)[1] and that will patch
the method on ActiveRecord::Base with my own custom version.


This is really a syntax question as I'm not sure how to override a method
that is part of a Module.

The ruby code is here:


The method I need to remove (ie: replace with a method that does nothing) is

~ Mike
Work: http://ClickableBliss.com
Play: http://MikeZornek.com

To unsubscribe or change your settings, visit: