【发布时间】:2016-10-23 07:10:08
【问题描述】:
我有一个带有这些关联的表 Bmp
class Bmp < ActiveRecord::Base
#associations
has_many :subareas, dependent: :destroy
belongs_to :scenario
和另一个表格子区域
class Subarea < ActiveRecord::Base
#associations
belongs_to :scenarios
belongs_to :soil
belongs_to :bmp
但是,当我尝试删除 bmp 时,它也应该删除我的分区,但它没有这样做。
def destroy
@bmp = Bmp.find(params[:id])
@bmp.destroy
我没有看到我搞砸了,任何想法都非常感谢!
【问题讨论】:
-
您确认子区域在
bmp_id字段中包含值吗? -
当您尝试破坏某些东西时,您能否发布服务器日志的转储
-
@Kumar 抱歉,我真的是 Rails 新手,你是什么意思?
标签: ruby-on-rails destroy belongs-to dependent-destroy