Browse Source

member: membership dependent destoy

Lou 3 years ago
parent
commit
144083354e
3 changed files with 2 additions and 2 deletions
  1. 1
    1
      app/models/user.rb
  2. 1
    1
      db/seeds.rb
  3. BIN
      erd.pdf

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

11
 
11
 
12
   has_many :tasks, foreign_key: 'owner_id', class_name: 'Task'
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
   has_many :teams, through: :memberships
15
   has_many :teams, through: :memberships
16
   
16
   
17
   has_secure_password
17
   has_secure_password

+ 1
- 1
db/seeds.rb View File

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

BIN
erd.pdf View File


Loading…
Cancel
Save