Acts_As_Ferret: disable_ferret and Callbacks

Does disable_ferret monkey with callbacks at all? I have a model in my
application that has associated models which perform callbacks after
their validation (they’re all instantiated around the same time). I
recently added a conditional call to disable ferret provided a flag and
I’m finding these callbacks aren’t quite working right.

Here’s a code sample:

class Model < ActiveRecord::Base
has_one :associated_model # This model will fill in some fields upon
it’s own validation

def save_with_activation_handling!
if active? # This part works
self.activated_at = Time.now
else
disable_ferret :once
self.activated_at = nil
end
save_without_activation_handling!
end

alias_method_chain :save!, :activation_handling
end

Any ideas?

Thank you,

James H.

On Mon, Jul 23, 2007 at 08:34:31PM +0200, James H. wrote:

Does disable_ferret monkey with callbacks at all? I have a model in my
application that has associated models which perform callbacks after
their validation (they’re all instantiated around the same time). I
recently added a conditional call to disable ferret provided a flag and
I’m finding these callbacks aren’t quite working right.

what exactly does this mean? Is Ferret not disabled, or are your
callbacks never called?

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

Jens K. wrote:

On Mon, Jul 23, 2007 at 08:34:31PM +0200, James H. wrote:

Does disable_ferret monkey with callbacks at all? I have a model in my
application that has associated models which perform callbacks after
their validation (they’re all instantiated around the same time). I
recently added a conditional call to disable ferret provided a flag and
I’m finding these callbacks aren’t quite working right.

what exactly does this mean? Is Ferret not disabled, or are your
callbacks never called?

The callbacks weren’t firing. It doesn’t matter though. I’ve since
approached the problem from a different angle.