質問編集履歴
4
show.html.erbの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -149,4 +149,19 @@
|
|
149
149
|
|
150
150
|
app/controllers/orders_controller.rb:24:in `order_params'
|
151
151
|
app/controllers/orders_controller.rb:11:in `create'
|
152
|
+
```
|
153
|
+
show.html.erb
|
154
|
+
```
|
155
|
+
# 省略
|
156
|
+
|
157
|
+
<% if user_signed_in? %>
|
158
|
+
<% if current_user.id == @food.user_id %>
|
159
|
+
<%= link_to '商品の編集', edit_food_path(@food.id), method: :get, class: "food-btn" %>
|
160
|
+
<%= link_to '削除', "/foods/#{@food.id}", method: :delete, class:'food-destroy' %>
|
161
|
+
<% else %>
|
162
|
+
<%= link_to '購入する',food_orders_path(@food.id), class:"food-btn", method: :post%>
|
163
|
+
<% end %>
|
164
|
+
<% end %>
|
165
|
+
|
166
|
+
# 省略
|
152
167
|
```
|
3
logの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -108,4 +108,45 @@
|
|
108
108
|
<%= f.text_field :phone_number, maxlength:"11"%>
|
109
109
|
<%= f.submit "購入" %>
|
110
110
|
<% end %>
|
111
|
+
```
|
112
|
+
|
113
|
+
log
|
114
|
+
```
|
115
|
+
Started GET "/foods/1" for ::1 at 2020-12-13 13:28:58 +0900
|
116
|
+
Processing by FoodsController#show as HTML
|
117
|
+
Parameters: {"id"=>"1"}
|
118
|
+
[1m[36mFood Load (0.4ms)[0m [1m[34mSELECT `foods`.* FROM `foods` WHERE `foods`.`id` = 1 LIMIT 1[0m
|
119
|
+
↳ app/controllers/foods_controller.rb:56:in `set_food'
|
120
|
+
Rendering foods/show.html.erb within layouts/application
|
121
|
+
[1m[36mUser Load (0.4ms)[0m [1m[34mSELECT `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1[0m
|
122
|
+
↳ app/views/shared/_header.html.erb:15
|
123
|
+
Rendered shared/_header.html.erb (Duration: 4.7ms | Allocations: 2467)
|
124
|
+
[1m[36mActiveStorage::Attachment Load (0.4ms)[0m [1m[34mSELECT `active_storage_attachments`.* FROM `active_storage_attachments` WHERE `active_storage_attachments`.`record_id` = 1 AND `active_storage_attachments`.`record_type` = 'Food' AND `active_storage_attachments`.`name` = 'image' LIMIT 1[0m
|
125
|
+
↳ app/views/foods/show.html.erb:11
|
126
|
+
[1m[36mActiveStorage::Blob Load (0.3ms)[0m [1m[34mSELECT `active_storage_blobs`.* FROM `active_storage_blobs` WHERE `active_storage_blobs`.`id` = 1 LIMIT 1[0m
|
127
|
+
↳ app/views/foods/show.html.erb:11
|
128
|
+
Rendered foods/show.html.erb within layouts/application (Duration: 9.5ms | Allocations: 4794)
|
129
|
+
[Webpacker] Everything's up-to-date. Nothing to do
|
130
|
+
Completed 200 OK in 90ms (Views: 86.0ms | ActiveRecord: 1.5ms | Allocations: 25558)
|
131
|
+
|
132
|
+
|
133
|
+
Started GET "/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSWhOMlF4YTJGaWFHYzFOR2czWjNoMU1XRXhkM0JtT0hkNGNUUnRlUVk2QmtWVU9oQmthWE53YjNOcGRHbHZia2tpUTJsdWJHbHVaVHNnWm1sc1pXNWhiV1U5SW5SbGNtbDVZV3RwTG1wd1p5STdJR1pwYkdWdVlXMWxLajFWVkVZdE9DY25kR1Z5YVhsaGEya3VhbkJuQmpzR1ZEb1JZMjl1ZEdWdWRGOTBlWEJsU1NJUGFXMWhaMlV2YW5CbFp3WTdCbFE9IiwiZXhwIjoiMjAyMC0xMi0xM1QwNDozMTozNC43MTFaIiwicHVyIjoiYmxvYl9rZXkifX0=--aa418a0630aa9d3b3d01b135de8251b42140df17/teriyaki.jpg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22teriyaki.jpg%22%3B+filename%2A%3DUTF-8%27%27teriyaki.jpg" for ::1 at 2020-12-13 13:28:58 +0900
|
134
|
+
Processing by ActiveStorage::DiskController#show as JPEG
|
135
|
+
Parameters: {"content_type"=>"image/jpeg", "disposition"=>"inline; filename=\"teriyaki.jpg\"; filename*=UTF-8''teriyaki.jpg", "encoded_key"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSWhOMlF4YTJGaWFHYzFOR2czWjNoMU1XRXhkM0JtT0hkNGNUUnRlUVk2QmtWVU9oQmthWE53YjNOcGRHbHZia2tpUTJsdWJHbHVaVHNnWm1sc1pXNWhiV1U5SW5SbGNtbDVZV3RwTG1wd1p5STdJR1pwYkdWdVlXMWxLajFWVkVZdE9DY25kR1Z5YVhsaGEya3VhbkJuQmpzR1ZEb1JZMjl1ZEdWdWRGOTBlWEJsU1NJUGFXMWhaMlV2YW5CbFp3WTdCbFE9IiwiZXhwIjoiMjAyMC0xMi0xM1QwNDozMTozNC43MTFaIiwicHVyIjoiYmxvYl9rZXkifX0=--aa418a0630aa9d3b3d01b135de8251b42140df17", "filename"=>"teriyaki"}
|
136
|
+
Completed 304 Not Modified in 2ms (ActiveRecord: 0.0ms | Allocations: 728)
|
137
|
+
|
138
|
+
|
139
|
+
Started POST "/foods/1/orders" for ::1 at 2020-12-13 13:29:02 +0900
|
140
|
+
Processing by OrdersController#create as HTML
|
141
|
+
Parameters: {"authenticity_token"=>"VgUl7/gmHxJZtJ0Nm4uuRp+MCFNYqE3o5Q+gXG6SzQCVDwNxbLnO4BbseoNR1L738ou63i7lt6TahMmTqTRJGg==", "food_id"=>"1"}
|
142
|
+
[1m[36mFood Load (0.5ms)[0m [1m[34mSELECT `foods`.* FROM `foods` WHERE `foods`.`id` = 1 LIMIT 1[0m
|
143
|
+
↳ app/controllers/orders_controller.rb:34:in `set_food'
|
144
|
+
Completed 400 Bad Request in 5ms (ActiveRecord: 0.5ms | Allocations: 1634)
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
ActionController::ParameterMissing (param is missing or the value is empty: address_order):
|
149
|
+
|
150
|
+
app/controllers/orders_controller.rb:24:in `order_params'
|
151
|
+
app/controllers/orders_controller.rb:11:in `create'
|
111
152
|
```
|
2
不備の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
param is missing or the value is empty: address_order
|
11
11
|
```
|
12
12
|
def order_params
|
13
|
-
|
13
|
+
# ↓この部分
|
14
14
|
params.require(:address_order).permit(:postal_code, :city, :street, :house_name, :phone_number).merge(user_id: current_user.id, food_id: params[:food_id])
|
15
15
|
end
|
16
16
|
```
|
1
状況の詳細
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,11 +10,14 @@
|
|
10
10
|
param is missing or the value is empty: address_order
|
11
11
|
```
|
12
12
|
def order_params
|
13
|
+
# ↓require(:address_order)
|
13
14
|
params.require(:address_order).permit(:postal_code, :city, :street, :house_name, :phone_number).merge(user_id: current_user.id, food_id: params[:food_id])
|
14
15
|
end
|
15
16
|
```
|
16
17
|
## 調べたこと
|
17
18
|
Googleで調べたところ、address_orderが無い又は空である。
|
19
|
+
・require(:address_order)があると保存はできるがそもそも商品購入フォームへいけなくなる(param is missing or the value is empty: address_orderとエラー)
|
20
|
+
・require(:address_order)が無いと商品購入フォームへ行けるがsubmit時に保存出来ない
|
18
21
|
|
19
22
|
##該当のソースコード
|
20
23
|
model
|