Pārlūkot izejas kodu

member: membership dependent destoy

Lou 3 gadus atpakaļ
vecāks
revīzija
144083354e
3 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 1
    1
      app/models/user.rb
  2. 1
    1
      db/seeds.rb
  3. Binārs
      erd.pdf

+ 1
- 1
app/models/user.rb Parādīt failu

@@ -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 Parādīt failu

@@ -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ārs
erd.pdf Parādīt failu


Notiek ielāde…
Atcelt
Saglabāt