How to make has many through polymorphic associations dependent in rails 3?
I have a polymorphic relationshi开发者_运维百科p in rails 3 and i am trying to make the through table dependent. What is the best way to handle that?
Would help to have some example code that you are trying this with. But the following is an example of how to get this to work.
class Listing < ActiveRecord::Base
has_many :activity_items, :as => :source, :dependent => :destroy
end
class ActivityItem < ActiveRecord::Base
belongs_to :source, :polymorphic => :true
end
That should work as expected.
精彩评论