相关疑难解决方法(0)

dependent =>在"has_many through"关联上销毁

当使用:through选项时,显然依赖=> destroy被忽略.

所以我有这个......

class Comment < ActiveRecord::Base
  has_many :comment_users, :dependent => :destroy
  has_many :users, :through => :comment_users
  ...
end
Run Code Online (Sandbox Code Playgroud)

...但删除评论不会导致关联的comment_user记录被删除.

那么,当使用时,对于级联删除,推荐的方法是什么:通过?

谢谢

activerecord ruby-on-rails has-many-through

48
推荐指数
3
解决办法
4万
查看次数