开发者

Rails: On-the-fly Destroy cascade?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜