質問編集履歴
1
Teamモデル、Userモデル及び中間テーブルを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,6 +38,66 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
+
```
|
42
|
+
|
43
|
+
team.rb
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
class Team < ApplicationRecord
|
48
|
+
|
49
|
+
has_many :team_users
|
50
|
+
|
51
|
+
has_many :users, through: :team_users
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
team_user.rb
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
class TeamUser < ApplicationRecord
|
66
|
+
|
67
|
+
belongs_to :team
|
68
|
+
|
69
|
+
belongs_to :user
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```
|
78
|
+
|
79
|
+
user.rb
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
class User < ApplicationRecord
|
84
|
+
|
85
|
+
devise :database_authenticatable, :registerable,
|
86
|
+
|
87
|
+
:recoverable, :rememberable, :validatable
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
has_many :team_users
|
92
|
+
|
93
|
+
has_many :teams, through: :team_users
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
```
|
100
|
+
|
41
101
|
|
42
102
|
|
43
103
|
|