Can I set up Cascade deleting in Rails?

后端 未结 5 729
情深已故
情深已故 2020-12-23 11:02

I know this is probably on the Internet somewhere but I can\'t find the answer here on Stackoverflow so I thought I may boost up the knowledge base here a little.

I\

5条回答
  •  既然无缘
    2020-12-23 11:28

    you can also set the :dependent option to :delete_all. :delete_all will issue a single SQL statement to delete all child records. because of this using :delete_all may give you better performance.

    has_many :memberships, dependent: :delete_all
    

提交回复
热议问题