浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

大家每天都有一个好心情 :)
  

rails cascade 级联删除[ruby]

 

用一次忘记一次,记下来。

:dependent - if set to :destroy all the associated objects are destroyed alongside this object by calling their destroy method. If set to :delete_all all associated objects are deleted without calling their destroy method. If set to :nullify all associated objects’ foreign keys are set to NULL without calling their save callbacks.

 

 

  1. belongs_to :xxx  
  2. has_many :xxxxs , :foreign_key => :xxxx_id , :dependent => :destroy  
  3. has_many :xxxxs:dependent => :destroy  
2008-10-30 11:27:11--回复文章

posted on 2010-11-25 13:24  lexus  阅读(457)  评论(0编辑  收藏  举报