Rails 问个关于 dependent 和 through 的问题

metal · 2012年01月12日 · 最后由 jhjguxin 回复于 2012年02月04日 · 2438 次阅读
class List < ActiveRecord::Base
  has_many :tasks , :dependent => :destroy
end

这样是不是意味着我删除一个 list,也会把 task 的内容删除?我也见过:destroy_all 这样的。挺茫然的。

class User < ActiveRecord::Base  
  has_many  :roles, :through => :user_roles  
end  

这个 through 我不知道有什么用

@metal 不清楚就用个用例 实际跑一下 即便是别人告诉你了 也记不住 我 blog 里面翻译了一部分的 rails guide search 一下吧

需要 登录 后方可回复, 如果你还没有账号请 注册新账号