Remove object from has_many but don't delete the original record in Rails?

夙愿已清 提交于 2019-11-30 04:40:48

You should not use the delete method on the Paragraphobject, but instead use the delete method of paragraphs relation, like this:

post.paragraphs.delete(Paragraph.find(paragraph_id))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!