質問編集履歴
7
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
included do
|
114
114
|
|
115
|
-
|
115
|
+
after_create -> { update_progress('payment') }
|
116
116
|
|
117
117
|
validate :check_combination_status
|
118
118
|
|
6
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
included do
|
114
114
|
|
115
|
-
before_
|
115
|
+
before_create -> { update_progress('payment') }
|
116
116
|
|
117
117
|
validate :check_combination_status
|
118
118
|
|
@@ -136,7 +136,7 @@
|
|
136
136
|
|
137
137
|
return if number.blank?
|
138
138
|
|
139
|
-
wf = Workflow.where(number: number
|
139
|
+
wf = Workflow.where(number: number)
|
140
140
|
|
141
141
|
unless wf.all? { |w| Status.find_by(compensation: w.compensation progress: progress).present? }
|
142
142
|
|
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,7 +104,7 @@
|
|
104
104
|
|
105
105
|
```ruby
|
106
106
|
|
107
|
-
module
|
107
|
+
module ProgressUpdateble
|
108
108
|
|
109
109
|
extend ActiveSupport::Concern
|
110
110
|
|
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -97,3 +97,57 @@
|
|
97
97
|
|
98
98
|
|
99
99
|
```
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
# 追記2
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
|
107
|
+
module AccidentProgressUpdateble
|
108
|
+
|
109
|
+
extend ActiveSupport::Concern
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
included do
|
114
|
+
|
115
|
+
before_save -> { update_progress('payment') }
|
116
|
+
|
117
|
+
validate :check_combination_status
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
def update_progress(status)
|
124
|
+
|
125
|
+
return if number.blank?
|
126
|
+
|
127
|
+
w = Workflow.where(approval_status: 'pending', number: number)
|
128
|
+
|
129
|
+
w.update_all(progress: status)
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
def check_combination_status
|
136
|
+
|
137
|
+
return if number.blank?
|
138
|
+
|
139
|
+
wf = Workflow.where(number: number
|
140
|
+
|
141
|
+
unless wf.all? { |w| Status.find_by(compensation: w.compensation progress: progress).present? }
|
142
|
+
|
143
|
+
errors[:base] << 'エラーメッセージ'
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
```
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
def self.find_by(compensation:, progress:)
|
82
82
|
|
83
|
-
|
83
|
+
STATUS_MANAGER.find_by(compensation: compensation, progress: progress)
|
84
84
|
|
85
85
|
end
|
86
86
|
|
@@ -88,7 +88,7 @@
|
|
88
88
|
|
89
89
|
def self.statuses
|
90
90
|
|
91
|
-
|
91
|
+
STATUS_MANAGER.statuses
|
92
92
|
|
93
93
|
end
|
94
94
|
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -63,3 +63,37 @@
|
|
63
63
|
・Rails 5.1.7
|
64
64
|
|
65
65
|
・Ruby 2.6.3
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
# 追記
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
|
73
|
+
StatusはCSVファイルをnewしてモデルのように扱っています。
|
74
|
+
|
75
|
+
class Status
|
76
|
+
|
77
|
+
attr_accessor :compensation :progress, :status
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
def self.find_by(compensation:, progress:)
|
82
|
+
|
83
|
+
ACCIDENT_STATUS_MANAGER.find_by(compensation: compensation, progress: progress)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
def self.statuses
|
90
|
+
|
91
|
+
ACCIDENT_STATUS_MANAGER.statuses
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,15 @@
|
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
|
15
|
+
def Workflow < ApplicationRecord
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
before_save -> { update_accident_progress('payment') }
|
20
|
+
|
21
|
+
|
22
|
+
|
15
|
-
def update_progress(status)
|
23
|
+
def update_progress(status)
|
16
24
|
|
17
25
|
return if number.blank? # numberがなければリターン
|
18
26
|
|
@@ -40,6 +48,8 @@
|
|
40
48
|
|
41
49
|
end
|
42
50
|
|
51
|
+
end
|
52
|
+
|
43
53
|
end
|
44
54
|
|
45
55
|
```
|