Open surzycki opened 13 years ago
Hmm... which fork are you using? My first test of dependent => destroy seems to work
My model looks like:
class Condition < ActiveRecord::Base
acts_as_citier
belongs_to :testable, :polymorphic => true
end
class ConditionSet < Condition
acts_as_citier
has_many conditions, :as => :testable, :dependent => destroy
end
And my rspec test using FactoryGirl to create one condition_set object with 3 associated conditions (of different types) look like this:
it "should destroy child associations" do
cond = Factory(:complex_cond_set)
(conds = cond.conditions).should_not be_empty
Condition.all.should_not be_empty
cond.destroy
conds.conditions.should be_empty
conds.each { |c| Condition.find_by_id(c.id).should be_nil }
end
This passes. I still haven't associated a non-citier model with a citier one, that's next up. For example: Model A has_many :conditions, :as => :testable, :dependent => :destroy
I'll let you know if that passes or not.
This passes. I still haven't associated a non-citier model with a citier one, that's next up. For example: Model A has_many :conditions, :as => :testable, :dependent => :destroy I'll let you know if that passes or not.
Is what is not working for me.
As well. If you don't save your citier model before attaching a non citier association to it, it will not properly populate the foreign keys...
Let me know if you have a different experience. I really love the concept, the performance gains from not having to do joins is a real bonus....
Doesn't seem to work for model associations on citier child models
Any model association on a citier child model will not be destroy when the parent is destroyed
ie
has_many :promotions, :dependent => :destroy
is on a citier model
promotions will hang around even after the citier model is wacked