开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜