RoR: NoMethodError when executing delete_all for a has_many relationship

后端 未结 5 1964
眼角桃花
眼角桃花 2021-01-22 18:01

My classes are as follows, with Customer inheriting from User using the single-table inheritance approach. User has attributes name and email while Order has destination.

<
5条回答
  •  自闭症患者
    2021-01-22 18:21

    for delete_all

    for example

     Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')")
      Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else'])
    

    for destroy_all

    for example

     Person.destroy_all("last_login < '2004-04-04'")
      Person.destroy_all(:status => "inactive")
    

提交回复
热议问题