質問編集履歴
2
モデル名変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
class
|
19
|
+
class PlanDivision < ApplicationRecord
|
20
20
|
|
21
21
|
belongs_to :plan
|
22
22
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
class
|
29
|
+
class Plan < ApplicationRecord
|
30
30
|
|
31
31
|
has_many :plan_divisions
|
32
32
|
|
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
plan =
|
39
|
+
plan = Plan.find 1
|
40
40
|
|
41
41
|
plan.divisions
|
42
42
|
|
1
eit
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,9 +8,9 @@
|
|
8
8
|
|
9
9
|
class Division < ApplicationRecord
|
10
10
|
|
11
|
-
has_many :
|
11
|
+
has_many :plan_divisions
|
12
12
|
|
13
|
-
has_many :
|
13
|
+
has_many :plans, through: :plan_divisions
|
14
14
|
|
15
15
|
end
|
16
16
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
class DemandDivision < ApplicationRecord
|
20
20
|
|
21
|
-
belongs_to :
|
21
|
+
belongs_to :plan
|
22
22
|
|
23
23
|
belongs_to :division
|
24
24
|
|
@@ -28,17 +28,17 @@
|
|
28
28
|
|
29
29
|
class Demand < ApplicationRecord
|
30
30
|
|
31
|
-
has_many :
|
31
|
+
has_many :plan_divisions
|
32
32
|
|
33
|
-
has_many :divisions, through: :
|
33
|
+
has_many :divisions, through: :plan_divisions
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
|
39
|
+
plan = Demand.find 1
|
40
40
|
|
41
|
-
|
41
|
+
plan.divisions
|
42
42
|
|
43
43
|
>#<Division::ActiveRecord_Associations_CollectionProxy:0x3ff082b3475c>
|
44
44
|
|
@@ -54,9 +54,9 @@
|
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
|
57
|
+
plans_divisions
|
58
58
|
|
59
|
-
|id|
|
59
|
+
|id|plan_id|division_code|
|
60
60
|
|
61
61
|
|:--|:--:|--:|
|
62
62
|
|
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
-
|
67
|
+
plans
|
68
68
|
|
69
69
|
|id|title|
|
70
70
|
|