質問編集履歴
4
画像の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -244,7 +244,7 @@
|
|
244
244
|
def period_get
|
245
245
|
date = params[:dream_list][:period]
|
246
246
|
Date.new date["period(1i)"].to_i,date["period(2i)"].to_i,date["period(3i)"].to_i
|
247
|
-
end ↑6
|
247
|
+
end ↑62行目はこちらになります。
|
248
248
|
end
|
249
249
|
|
250
250
|
```
|
@@ -304,7 +304,7 @@
|
|
304
304
|
|
305
305
|
##### 状況
|
306
306
|
form_withからデータを追加して送信すると、以下のエラーが表示されます。
|
307
|
-

|
308
308
|
値がnilになっていますが、送信後のdbには格納されているみたです。
|
309
309
|
```
|
310
310
|
Parameters: {"authenticity_token"=>"[FILTERED]", "dream_list"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x00007f324c19c190 @tempfile=#<Tempfile:/tmp/RackMultipart20220504-11279-1he4vwi.jpg>, @original_filename="dummy_image.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"dream_list[image]\"; filename=\"dummy_image.jpg\"\r\nContent-Type: image/jpeg\r\n">, "dream"=>"aaa", "period(1i)"=>"2022", "period(2i)"=>"5", "period(3i)"=>"4", "detail"=>"ああああ", "category"=>"仕事"}, "commit"=>"投稿"}
|
3
コードの追加、補足追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -185,7 +185,10 @@
|
|
185
185
|
class DreamListsController < ApplicationController
|
186
186
|
require 'date'
|
187
187
|
|
188
|
+
def new
|
188
|
-
|
189
|
+
@dream_list = DreamList.new
|
190
|
+
end
|
191
|
+
|
189
192
|
def create
|
190
193
|
@dream_list = current_user.dream_lists.new(dream_list_params)
|
191
194
|
if @dream_list.save
|
@@ -201,8 +204,35 @@
|
|
201
204
|
@dream_lists = current_user.dream_lists.page(params[:page])
|
202
205
|
end
|
203
206
|
|
207
|
+
def show
|
208
|
+
@dream_list = current_user.dream_lists.find(params[:id])
|
209
|
+
end
|
210
|
+
|
211
|
+
def edit
|
212
|
+
@dream_list = current_user.dream_lists.find(params[:id])
|
213
|
+
end
|
214
|
+
|
215
|
+
def update
|
216
|
+
@dream_list = current_user.dream_lists.find(params[:id])
|
217
|
+
if @dream_list.update(dream_list_params)
|
218
|
+
redirect_to dream_list_path(@dream_list.id)
|
219
|
+
flash[:notice] = "更新に成功しました。"
|
220
|
+
else
|
204
|
-
|
221
|
+
render :edit
|
205
|
-
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def destroy
|
226
|
+
@dream_list = current_user.dream_lists.find(params[:id])
|
227
|
+
@dream_list.destroy
|
228
|
+
redirect_to dream_lists_path
|
229
|
+
flash[:notice] = "1つ夢を削除しました。"
|
230
|
+
end
|
231
|
+
|
232
|
+
def search_dream_list
|
233
|
+
@dream_list = DreamList.new
|
234
|
+
@dream_lists = DreamList.search(params[:keyword])
|
235
|
+
end
|
206
236
|
|
207
237
|
private
|
208
238
|
|
@@ -210,12 +240,30 @@
|
|
210
240
|
params.require(:dream_list).permit(:dream, :period, :detail, :image, :category)
|
211
241
|
end
|
212
242
|
|
243
|
+
|
213
244
|
def period_get
|
214
245
|
date = params[:dream_list][:period]
|
215
|
-
Date.new date["period(1i)"].to_i,date["period(2i)"].to_i,
|
246
|
+
Date.new date["period(1i)"].to_i,date["period(2i)"].to_i,date["period(3i)"].to_i
|
216
|
-
end
|
247
|
+
end ↑60行目はこちらになります。
|
217
248
|
end
|
218
249
|
|
250
|
+
```
|
251
|
+
new.html.erb
|
252
|
+
```
|
253
|
+
<div class="container mt-4 mb-4">
|
254
|
+
<div class="card mx-auto col-lg-8 shadow p-3 bg-white">
|
255
|
+
<h2>New Dream</h2>
|
256
|
+
<%= render "dream_lists/error_message", dream_list: @dream_list %>
|
257
|
+
<%= form_with model: @dream_list do |form| %> ←form_withはこちらです
|
258
|
+
<div class="ml-3 mt-3">
|
259
|
+
<%= render "dream_lists/form", form: form %>
|
260
|
+
<div class="mt-3 text-center">
|
261
|
+
<%= form.submit "投稿", class: "btn btn-sm btn-secondary" %>
|
262
|
+
</div>
|
263
|
+
</div>
|
264
|
+
<% end %>
|
265
|
+
</div>
|
266
|
+
</div>
|
219
267
|
```
|
220
268
|
_form.html.erb
|
221
269
|
```
|
@@ -223,7 +271,7 @@
|
|
223
271
|
<%= form.label :period , "達成日 :", class: "form_label" %>
|
224
272
|
</div>
|
225
273
|
<div class="col-md-4">
|
226
|
-
<%= form.date_select(:period, start_year: 2022, date_separator: '/') %>
|
274
|
+
<%= form.date_select(:period, start_year: 2022, date_separator: '/') %> ←こちらをdate_selectに変更しました。
|
227
275
|
<!--<input type="text" id="userYear" >年
|
228
276
|
<input type="text" id="userMonth">月
|
229
277
|
<input type="text" id="userDate" >日-->
|
@@ -236,7 +284,7 @@
|
|
236
284
|
<td><%= check_box_tag '', '' %></td>
|
237
285
|
<td><%= link_to dream_list.dream, dream_list_path(dream_list.id) %></td>
|
238
286
|
<td>
|
239
|
-
<%= dream_list.period %>
|
287
|
+
<%= dream_list.period %> ←編集済みのcodeです
|
240
288
|
<td>
|
241
289
|
<%= link_to edit_dream_list_path(dream_list) do %>
|
242
290
|
<i class="fas fa-edit"></i>
|
2
カラムを変更し、date_selectタグ使用して実装することに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
## 実装コード
|
17
17
|
ER図
|
18
|
-

|
19
19
|
新規投稿フォーム画面
|
20
20
|

|
21
21
|
schema.rb
|
@@ -98,22 +98,7 @@
|
|
98
98
|
パーシャルファイル
|
99
99
|
dream_lists/_form.html.erb
|
100
100
|
```
|
101
|
-
<div class="row mt-3">
|
102
|
-
<div class="col-md-4">
|
103
|
-
<%= form.label :image, "画像 :", class: "form_label" %>
|
104
|
-
|
101
|
+
<!--省略-->
|
105
|
-
<div class="col-md-4">
|
106
|
-
<%= form.file_field :image, accept: "image/*", class: "form-control-file" %>
|
107
|
-
</div>
|
108
|
-
</div>
|
109
|
-
<div class="row mt-3">
|
110
|
-
<div class="col-md-4">
|
111
|
-
<%= form.label :dream, "夢 :", class: "form_label" %>
|
112
|
-
</div>
|
113
|
-
<div class="col-md-4">
|
114
|
-
<%= form.text_field :dream, class: "form-control-sm" %>
|
115
|
-
</div>
|
116
|
-
</div>
|
117
102
|
<div class="row mt-3">
|
118
103
|
<div class="col-md-4">
|
119
104
|
<%= form.label :countdown , "達成日 :", class: "form_label" %>
|
@@ -124,22 +109,7 @@
|
|
124
109
|
<input type="text" id="userMonth">月
|
125
110
|
<input type="text" id="userDate" >日
|
126
111
|
</div>
|
127
|
-
<
|
112
|
+
<!--省略-->
|
128
|
-
<div class="row mt-3">
|
129
|
-
<div class="col-md-4">
|
130
|
-
<%= form.label :detail, "フリー(意気込み) :", class: "form_label" %>
|
131
|
-
</div>
|
132
|
-
<div class="col-md-4">
|
133
|
-
<%= form.text_area :detail, size: "40x3", class: "form-control" %>
|
134
|
-
</div>
|
135
|
-
</div>
|
136
|
-
<div class="row mt-3">
|
137
|
-
<div class="col-md-4">
|
138
|
-
<%= form.label :category, "カテゴリー :", class: "form_label" %>
|
139
|
-
</div>
|
140
|
-
<div class="col-md-4">
|
141
|
-
<%= form.text_field :category, class: "form-control-sm" %>
|
142
|
-
</div>
|
143
113
|
</div>
|
144
114
|
```
|
145
115
|
表示場所コード
|
@@ -153,14 +123,7 @@
|
|
153
123
|
<div class="row">
|
154
124
|
<div class="col-md-9">
|
155
125
|
<table class="table table-striped text-white">
|
156
|
-
<
|
126
|
+
<!--省略-->
|
157
|
-
<tr>
|
158
|
-
<th></th>
|
159
|
-
<th>夢</th>
|
160
|
-
<th>達成日</th>
|
161
|
-
<th></th>
|
162
|
-
</tr>
|
163
|
-
</thead>
|
164
127
|
<tbody>
|
165
128
|
<% @dream_lists.each do |dream_list| %>
|
166
129
|
<tr>
|
@@ -199,6 +162,81 @@
|
|
199
162
|
}
|
200
163
|
</script>
|
201
164
|
</td>
|
165
|
+
<td>
|
166
|
+
<!--省略-->
|
167
|
+
</div>
|
168
|
+
```
|
169
|
+
|
170
|
+
## 変更後のcord
|
171
|
+
schema.rb
|
172
|
+
```
|
173
|
+
create_table "dream_lists", force: :cascade do |t|
|
174
|
+
t.string "dream", null: false
|
175
|
+
t.date "period", null: false ←こちらをdata型periodに変更しました。
|
176
|
+
t.text "detail"
|
177
|
+
t.string "category", null: false
|
178
|
+
t.datetime "created_at", precision: 6, null: false
|
179
|
+
t.datetime "updated_at", precision: 6, null: false
|
180
|
+
t.integer "user_id"
|
181
|
+
end
|
182
|
+
```
|
183
|
+
dream_lists_controller
|
184
|
+
```
|
185
|
+
class DreamListsController < ApplicationController
|
186
|
+
require 'date'
|
187
|
+
|
188
|
+
<!--省略-->
|
189
|
+
def create
|
190
|
+
@dream_list = current_user.dream_lists.new(dream_list_params)
|
191
|
+
if @dream_list.save
|
192
|
+
@dream_list.update(period: period_get)
|
193
|
+
redirect_to dream_lists_path
|
194
|
+
flash[:notice] = "1つ夢が追加されました。"
|
195
|
+
else
|
196
|
+
render :new
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def index
|
201
|
+
@dream_lists = current_user.dream_lists.page(params[:page])
|
202
|
+
end
|
203
|
+
|
204
|
+
<!--省略-->
|
205
|
+
|
206
|
+
|
207
|
+
private
|
208
|
+
|
209
|
+
def dream_list_params
|
210
|
+
params.require(:dream_list).permit(:dream, :period, :detail, :image, :category)
|
211
|
+
end
|
212
|
+
|
213
|
+
def period_get
|
214
|
+
date = params[:dream_list][:period]
|
215
|
+
Date.new date["period(1i)"].to_i,date["period(2i)"].to_i,pdate["period(3i)"].to_i
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
```
|
220
|
+
_form.html.erb
|
221
|
+
```
|
222
|
+
<div class="col-md-4">
|
223
|
+
<%= form.label :period , "達成日 :", class: "form_label" %>
|
224
|
+
</div>
|
225
|
+
<div class="col-md-4">
|
226
|
+
<%= form.date_select(:period, start_year: 2022, date_separator: '/') %>
|
227
|
+
<!--<input type="text" id="userYear" >年
|
228
|
+
<input type="text" id="userMonth">月
|
229
|
+
<input type="text" id="userDate" >日-->
|
230
|
+
</div>
|
231
|
+
```
|
232
|
+
index.html.erb
|
233
|
+
```
|
234
|
+
<% @dream_lists.each do |dream_list| %>
|
235
|
+
<tr>
|
236
|
+
<td><%= check_box_tag '', '' %></td>
|
237
|
+
<td><%= link_to dream_list.dream, dream_list_path(dream_list.id) %></td>
|
238
|
+
<td>
|
239
|
+
<%= dream_list.period %>
|
202
240
|
<td>
|
203
241
|
<%= link_to edit_dream_list_path(dream_list) do %>
|
204
242
|
<i class="fas fa-edit"></i>
|
@@ -209,30 +247,24 @@
|
|
209
247
|
</td>
|
210
248
|
</tr>
|
211
249
|
<% end %>
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
```
|
227
|
-
|
228
|
-
```
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
お手数をお掛けしますが、ご回答頂けますと幸いです。
|
234
|
-
宜しくお願い致します。
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
250
|
+
```
|
251
|
+
##### 変更点の詳細
|
252
|
+
・カラムをdate型periodに変更しました。
|
253
|
+
・form_withからdate_selectタグを使用して日付をindex.html.erbに表示することに変更しました。
|
254
|
+
・dream_lists_controllerにcordを追加しました。
|
255
|
+
※一旦Javascript での動的な実装は中断し、form_with画面から投稿したデータをindex.html.erbに表示させたいです。
|
256
|
+
|
257
|
+
##### 状況
|
258
|
+
form_withからデータを追加して送信すると、以下のエラーが表示されます。
|
259
|
+

|
260
|
+
値がnilになっていますが、送信後のdbには格納されているみたです。
|
261
|
+
```
|
262
|
+
Parameters: {"authenticity_token"=>"[FILTERED]", "dream_list"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x00007f324c19c190 @tempfile=#<Tempfile:/tmp/RackMultipart20220504-11279-1he4vwi.jpg>, @original_filename="dummy_image.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"dream_list[image]\"; filename=\"dummy_image.jpg\"\r\nContent-Type: image/jpeg\r\n">, "dream"=>"aaa", "period(1i)"=>"2022", "period(2i)"=>"5", "period(3i)"=>"4", "detail"=>"ああああ", "category"=>"仕事"}, "commit"=>"投稿"}
|
263
|
+
```
|
264
|
+
```
|
265
|
+
Date.new date["period(1i)"].to_i,date["period(2i)"].to_i,date["period(3i)"].to_i
|
266
|
+
```
|
267
|
+
の記述の仕方が間違っているのでしょうか?
|
268
|
+
|
269
|
+
|
270
|
+
|
1
実装コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,7 +13,226 @@
|
|
13
13
|
|
14
14
|
こちらの記事は時間まで表示していますが、年、月のみフォーム画面から入力して「あと〇日」と日付だけ表示させたいです。
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
## 実装コード
|
17
|
+
ER図
|
18
|
+

|
19
|
+
新規投稿フォーム画面
|
20
|
+

|
21
|
+
schema.rb
|
22
|
+
```
|
23
|
+
create_table "dream_lists", force: :cascade do |t|
|
24
|
+
t.string "dream", null: false
|
25
|
+
t.string "period", null: false
|
26
|
+
t.text "detail"
|
27
|
+
t.string "category", null: false
|
28
|
+
t.datetime "created_at", precision: 6, null: false
|
29
|
+
t.datetime "updated_at", precision: 6, null: false
|
30
|
+
t.integer "user_id"
|
31
|
+
t.datetime "countdown"
|
32
|
+
end
|
33
|
+
```
|
34
|
+
routes.rb
|
35
|
+
```
|
36
|
+
Rails.application.routes.draw do
|
37
|
+
get '/login' => 'sessions#new'
|
38
|
+
post '/login' => 'sessions#create'
|
39
|
+
delete '/logout' => 'sessions#destroy'
|
40
|
+
resources :users
|
41
|
+
root to: 'homes#top'
|
42
|
+
resources :dream_lists
|
43
|
+
resources :plans
|
44
|
+
get '/search_dream_list' => 'dream_lists#search_dream_list' # カテゴリー検索
|
45
|
+
end
|
46
|
+
|
47
|
+
```
|
48
|
+
dream_lists_controller.rb
|
49
|
+
```
|
50
|
+
class DreamListsController < ApplicationController
|
51
|
+
def new
|
52
|
+
@dream_list = DreamList.new
|
53
|
+
end
|
54
|
+
|
55
|
+
def create
|
56
|
+
@dream_list = current_user.dream_lists.new(dream_list_params)
|
57
|
+
if @dream_list.save
|
58
|
+
redirect_to dream_lists_path
|
59
|
+
flash[:notice] = "1つ夢が追加されました。"
|
60
|
+
else
|
61
|
+
render :new
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def index
|
66
|
+
@dream_lists = current_user.dream_lists
|
67
|
+
end
|
68
|
+
|
69
|
+
def show
|
70
|
+
@dream_list = current_user.dream_lists.find(params[:id])
|
71
|
+
end
|
72
|
+
|
73
|
+
<!--edit,upsate,destroy省略-->
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def dream_list_params
|
78
|
+
params.require(:dream_list).permit(:dream, :period, :detail, :image, :category, :countdown)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
```
|
82
|
+
new.html.erb
|
83
|
+
```
|
84
|
+
<div class="container mt-4 mb-4">
|
85
|
+
<div class="card mx-auto col-lg-8 shadow p-3 bg-white">
|
86
|
+
<h2>New Dream</h2>
|
87
|
+
<%= form_with model: @dream_list,local: true do |form| %>
|
88
|
+
<div class="ml-3 mt-3">
|
89
|
+
<%= render "dream_lists/form", form: form %>
|
90
|
+
<div class="mt-3 text-center">
|
91
|
+
<%= form.submit "投稿", class: "btn btn-sm btn-secondary" %>
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
<% end %>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
```
|
98
|
+
パーシャルファイル
|
99
|
+
dream_lists/_form.html.erb
|
100
|
+
```
|
101
|
+
<div class="row mt-3">
|
102
|
+
<div class="col-md-4">
|
103
|
+
<%= form.label :image, "画像 :", class: "form_label" %>
|
104
|
+
</div>
|
105
|
+
<div class="col-md-4">
|
106
|
+
<%= form.file_field :image, accept: "image/*", class: "form-control-file" %>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
<div class="row mt-3">
|
110
|
+
<div class="col-md-4">
|
111
|
+
<%= form.label :dream, "夢 :", class: "form_label" %>
|
112
|
+
</div>
|
113
|
+
<div class="col-md-4">
|
114
|
+
<%= form.text_field :dream, class: "form-control-sm" %>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
<div class="row mt-3">
|
118
|
+
<div class="col-md-4">
|
119
|
+
<%= form.label :countdown , "達成日 :", class: "form_label" %>
|
120
|
+
</div>
|
121
|
+
<div class="col-md-4">
|
122
|
+
<%= form.hidden_field :countdown, :id => "countdown.id" %>
|
123
|
+
<input type="text" id="userYear" >年
|
124
|
+
<input type="text" id="userMonth">月
|
125
|
+
<input type="text" id="userDate" >日
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
<div class="row mt-3">
|
129
|
+
<div class="col-md-4">
|
130
|
+
<%= form.label :detail, "フリー(意気込み) :", class: "form_label" %>
|
131
|
+
</div>
|
132
|
+
<div class="col-md-4">
|
133
|
+
<%= form.text_area :detail, size: "40x3", class: "form-control" %>
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
<div class="row mt-3">
|
137
|
+
<div class="col-md-4">
|
138
|
+
<%= form.label :category, "カテゴリー :", class: "form_label" %>
|
139
|
+
</div>
|
140
|
+
<div class="col-md-4">
|
141
|
+
<%= form.text_field :category, class: "form-control-sm" %>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
```
|
145
|
+
表示場所コード
|
146
|
+
dream_lists/index.html.erb
|
147
|
+
```
|
148
|
+
<div class="container mt-4 mb-4">
|
149
|
+
<div class="text-right">
|
150
|
+
<%= link_to "+dream", new_dream_list_path, class: "btn btn-secondary btn-sm" %>
|
151
|
+
</div>
|
152
|
+
<h2>Many Dreams</h2>
|
153
|
+
<div class="row">
|
154
|
+
<div class="col-md-9">
|
155
|
+
<table class="table table-striped text-white">
|
156
|
+
<thead>
|
157
|
+
<tr>
|
158
|
+
<th></th>
|
159
|
+
<th>夢</th>
|
160
|
+
<th>達成日</th>
|
161
|
+
<th></th>
|
162
|
+
</tr>
|
163
|
+
</thead>
|
164
|
+
<tbody>
|
165
|
+
<% @dream_lists.each do |dream_list| %>
|
166
|
+
<tr>
|
167
|
+
<td><%= check_box_tag '', '' %></td>
|
168
|
+
<td><%= link_to dream_list.dream, dream_list_path(dream_list.id) %></td>
|
169
|
+
<td>
|
170
|
+
<p id="CountDownTime" ></p>
|
171
|
+
<script>
|
172
|
+
function showCountdown() {
|
173
|
+
// 現在日時を数値に変換
|
174
|
+
var nowDate = new Date();
|
175
|
+
var dnumNow = nowDate.getTime();
|
176
|
+
|
177
|
+
// 指定日時を数値に変換
|
178
|
+
var inputYear = document.getElementById("userYear").value;
|
179
|
+
var inputMonth = document.getElementById("userMonth").value - 1;
|
180
|
+
var inputDate = document.getElementById("userDate").value;
|
181
|
+
var dnumTarget = targetDate.getTime();
|
182
|
+
|
183
|
+
// 引き算して残日数を計算
|
184
|
+
var diffMSec = dnumTarget - dnumNow;
|
185
|
+
var diffDays = diffMSec / ( 1000 * 60 * 60 * 24 );
|
186
|
+
var showDays = Math.ceil( diffDays ); // 小数点以下を切り上げる
|
187
|
+
|
188
|
+
// 表示
|
189
|
+
var Msg;
|
190
|
+
if( showDays >= 0 ) {
|
191
|
+
Msg = "あと " + showDays + "日";
|
192
|
+
}
|
193
|
+
else {
|
194
|
+
Msg = "達成日は " + (showDays * -1) + "日前に過ぎました。";
|
195
|
+
}
|
196
|
+
|
197
|
+
document.getElementById("CountDownTime").innerHTML = Msg;
|
198
|
+
document.getElementById("countdown.id").value = targetDate;
|
199
|
+
}
|
200
|
+
</script>
|
201
|
+
</td>
|
202
|
+
<td>
|
203
|
+
<%= link_to edit_dream_list_path(dream_list) do %>
|
204
|
+
<i class="fas fa-edit"></i>
|
205
|
+
<% end %>
|
206
|
+
<%= link_to dream_list_path(dream_list), method: :delete, data: { confirm: '削除しますか?' } do %>
|
207
|
+
<i class="fas fa-eraser"></i>
|
208
|
+
<% end %>
|
209
|
+
</td>
|
210
|
+
</tr>
|
211
|
+
<% end %>
|
212
|
+
</tbody>
|
213
|
+
</table>
|
214
|
+
</div>
|
215
|
+
<div class="col-md-2">
|
216
|
+
<p>カテゴリー</p>
|
217
|
+
<% @dream_lists.each do |dream_list| %>
|
218
|
+
<i class="fas fa-tag"></i>
|
219
|
+
<%= link_to dream_list.category, search_dream_list_path(keyword: dream_list.category) %>
|
220
|
+
<% end %>
|
221
|
+
</div>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
```
|
225
|
+
フォームに値を入力後のdbの中
|
226
|
+
```
|
227
|
+
Parameters: {"authenticity_token"=>"[FILTERED]", "dream_list"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x00007f9fc97fc978 @tempfile=#<Tempfile:/tmp/RackMultipart20220502-13102-u5tdvg.jpg>, @original_filename="no_image.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"dream_list[image]\"; filename=\"no_image.jpg\"\r\nContent-Type: image/jpeg\r\n">, "dream"=>"aaa", "countdown"=>"", "detail"=>"aaa", "category"=>"仕事"}, "commit"=>"投稿"}
|
228
|
+
```
|
229
|
+
dbの中を確認したところ、countdownカラム以外の値は格納されているのですが、countdownカラムのみ値が保存されていないです。
|
230
|
+
ルーティングの記述する順番も関係すると思い入れ替えて実行してみましたが、同じ結果でした。
|
231
|
+
フォームからの受け渡しの間で問題が起こっていると思うのですが、どこが問題かが分からないです。
|
232
|
+
|
233
|
+
お手数をお掛けしますが、ご回答頂けますと幸いです。
|
234
|
+
宜しくお願い致します。
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|