开发者

Rails: On-the-fly Destroy cascade?

开发者 https://www.devze.com 2023-04-06 04:05 出处:网络
I know that destroy cascade will work if prop开发者_如何学Pythoner relationships are setup in the models, but I want to know whether there is a way to destroy cascade on-the-fly, without needing to ha

I know that destroy cascade will work if prop开发者_如何学Pythoner relationships are setup in the models, but I want to know whether there is a way to destroy cascade on-the-fly, without needing to have everything setup? Maybe something like model.destroy :cascade?

Or am I limited to raw SQL in this case?


I haven't heard of way of doing it on the fly, but rather than using raw SQL try this:

AssociatedModel.destroy_all(:model_id => @model.id)
@model.destroy
0

精彩评论

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