質問編集履歴
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -100,9 +100,9 @@
|
|
100
100
|
|
101
101
|
@score = Score.find_by(round_id: params[:round_id], hole_number: params[:hole_number])
|
102
102
|
|
103
|
-
@score.update(hole_score:
|
103
|
+
@score.update(hole_score: @score)
|
104
104
|
|
105
|
-
redirect_to
|
105
|
+
redirect_to score_card_path
|
106
106
|
|
107
107
|
end
|
108
108
|
|
@@ -118,13 +118,15 @@
|
|
118
118
|
|
119
119
|
#edit_score.html.erb
|
120
120
|
|
121
|
-
<%= form_with
|
121
|
+
<%= form_with url:hole_score_update_path do |f| %>
|
122
122
|
|
123
123
|
<%= f.text_field :hole_score %>
|
124
124
|
|
125
125
|
<%= f.submit "編集する" %>
|
126
126
|
|
127
127
|
<% end %>
|
128
|
+
|
129
|
+
|
128
130
|
|
129
131
|
```
|
130
132
|
|
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,11 +20,13 @@
|
|
20
20
|
|
21
21
|
get "archives/show/:round_id",to: 'archives#show' ,as: 'score_card'
|
22
22
|
|
23
|
-
get "archives/edit/:round_id",to: 'archives#edit' ,as: 'score
|
23
|
+
get "archives/edit/:round_id",to: 'archives#edit' ,as: 'scorecard_edit'
|
24
24
|
|
25
|
-
get "archives/edit/:round_id/:hole_number",to: 'archives#edit_score' ,as: '
|
25
|
+
get "archives/edit/:round_id/:hole_number",to: 'archives#edit_score' ,as: 'edit_hole_score'
|
26
26
|
|
27
|
+
get "archives/edit_score/:round_id/:hole_number",to: 'archives#hole_score_edit' ,as: 'score_update'
|
28
|
+
|
27
|
-
p
|
29
|
+
post "archives/edit/:round_id/:hole_number",to: 'archives#update' ,as: 'hole_score_update'
|
28
30
|
|
29
31
|
```
|
30
32
|
|
@@ -84,29 +86,23 @@
|
|
84
86
|
|
85
87
|
end
|
86
88
|
|
89
|
+
def hole_score_edit
|
90
|
+
|
91
|
+
@score = Score.find_by(round_id: params[:round_id], hole_number: params[:hole_number])
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def create
|
96
|
+
|
97
|
+
end
|
98
|
+
|
87
99
|
def update
|
88
100
|
|
89
101
|
@score = Score.find_by(round_id: params[:round_id], hole_number: params[:hole_number])
|
90
102
|
|
91
|
-
|
103
|
+
@score.update(hole_score: params[:hole_score])
|
92
104
|
|
93
|
-
if @score.update(hole_score: @score)
|
94
|
-
|
95
|
-
# flash[:success] = 'Message は正常に更新されました'
|
96
|
-
|
97
|
-
|
105
|
+
redirect_to("/")
|
98
|
-
|
99
|
-
else
|
100
|
-
|
101
|
-
# flash.now[:danger] = 'Message は更新されませんでした'
|
102
|
-
|
103
|
-
# render :edit
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
def create
|
110
106
|
|
111
107
|
end
|
112
108
|
|
@@ -122,13 +118,11 @@
|
|
122
118
|
|
123
119
|
#edit_score.html.erb
|
124
120
|
|
125
|
-
<%= form_with
|
121
|
+
<%= form_with model: @score do |f| %>
|
126
|
-
|
127
|
-
<%= f.label :hole_score, 'スコア' %>
|
128
122
|
|
129
123
|
<%= f.text_field :hole_score %>
|
130
124
|
|
131
|
-
<%= f.submit
|
125
|
+
<%= f.submit "編集する" %>
|
132
126
|
|
133
127
|
<% end %>
|
134
128
|
|
@@ -150,11 +144,11 @@
|
|
150
144
|
|
151
145
|
<p>プレイヤー名: <%= @score_card_course.user.name %></p>
|
152
146
|
|
153
|
-
<p>プレイ
|
147
|
+
<p>プレイ日時: <%= @score_card_course.created_at.strftime('%Y/%m/%d') %></p>
|
154
148
|
|
155
149
|
<p>トータルスコア: <%= format('%+d', @score_sum + 72) %></p>
|
156
150
|
|
157
|
-
|
151
|
+
|
158
152
|
|
159
153
|
<% @score_card_score.each do |m| %>
|
160
154
|
|
@@ -162,7 +156,7 @@
|
|
162
156
|
|
163
157
|
<span> <%= format('%+d',m.hole_score) %> </span>
|
164
158
|
|
165
|
-
<span> <%= link_to "編集",
|
159
|
+
<span> <%= link_to "編集", edit_hole_score_path(round_id: m.round_id, hole_number: m.hole_number) %> </span><br>
|
166
160
|
|
167
161
|
<% end %>
|
168
162
|
|