Sfoglia il codice sorgente

member: membership dependent destoy

Lou 3 anni fa
parent
commit
144083354e
3 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 1
    1
      app/models/user.rb
  2. 1
    1
      db/seeds.rb
  3. BIN
      erd.pdf

+ 1
- 1
app/models/user.rb Vedi File

@@ -11,7 +11,7 @@ class User < ApplicationRecord
11 11
 
12 12
   has_many :tasks, foreign_key: 'owner_id', class_name: 'Task'
13 13
   
14
-  has_many :memberships, foreign_key: :member_id
14
+  has_many :memberships, foreign_key: :member_id, dependent: :destroy
15 15
   has_many :teams, through: :memberships
16 16
   
17 17
   has_secure_password

+ 1
- 1
db/seeds.rb Vedi File

@@ -48,7 +48,7 @@ end
48 48
 User.create(username: "admin", email: "admin@email.com", password: "azerty", is_admin: true)
49 49
 puts "Created Admin"
50 50
 
51
-60.times do |i|
51
+30.times do |i|
52 52
   task = Task.create(
53 53
     name: Faker::Verb.ing_form,
54 54
     description: Faker::Fantasy::Tolkien.poem,

BIN
erd.pdf Vedi File


Loading…
Annulla
Salva