I am after a nice way to disable (not destroy, delete nor nullify) all
associated records. I’m a hoarder, I don’t want to get rid of anything
but I
want to stop records being visible.
I have a disabled boolean in my tables and if I disable the top record
in
the association (say the association is 5-6 levels deep), I would like
to
cleanly disable its children.
I’ve looked in the source to see how AR collects all the records but
couldn’t easily track it back.
The way I’m thinking is to extend …
has_many :products do
def disable
products = all(:conditions => ‘’, :include => associations)
products.each do
## but here it gets messy
end
end
end
Does anyone have a nicer solution to this?
Thank you
-ants