删除员工后,删除Works_On和Dependent中的引用行

时间:2019-02-16 00:44:23

标签: postgresql

archer:
  name: Sterling Archer
  email: duchess@example.gov
  password_digest: <%= User.digest('password') %>
  activated: true
  activated_at: <%= Time.zone.now %>

lana:
  name: Lana Kane
  email: hands@example.gov
  password_digest: <%= User.digest('password') %>
  activated: true
  activated_at: <%= Time.zone.now %>

问题是我不知道如何为其添加CASCADE DELETE

链接到数据库:https://www.db-fiddle.com/f/xhEj2sAgdTMABBkCtJvmoC/0#&togetherjs=z3CKywAccH

1 个答案:

答案 0 :(得分:0)

if current_user == product.user
  flash[:alert] = "You cannot purchase your own property"