开发者

How to make has many through polymorphic associations dependent in rails 3?

开发者 https://www.devze.com 2023-02-20 13:08 出处:网络
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 t

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消