質問編集履歴
2
binding.pry無しでのログを追加。マイグレーションファイルを追加。
test
CHANGED
File without changes
|
test
CHANGED
@@ -108,8 +108,6 @@
|
|
108
108
|
|
109
109
|
```
|
110
110
|
|
111
|
-
|
112
|
-
|
113
111
|
######ビューファイル(new.html.haml)
|
114
112
|
|
115
113
|
```
|
@@ -168,7 +166,31 @@
|
|
168
166
|
|
169
167
|
```
|
170
168
|
|
171
|
-
|
169
|
+
######マイグレーションファイル
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
class CreateDrinks < ActiveRecord::Migration[6.0]
|
174
|
+
|
175
|
+
def change
|
176
|
+
|
177
|
+
create_table :drinks do |t|
|
178
|
+
|
179
|
+
t.string :name
|
180
|
+
|
181
|
+
t.string :price
|
182
|
+
|
183
|
+
t.string :comment
|
184
|
+
|
185
|
+
t.timestamps
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
```
|
172
194
|
|
173
195
|
### 試したこと
|
174
196
|
|
@@ -178,6 +200,8 @@
|
|
178
200
|
|
179
201
|
```
|
180
202
|
|
203
|
+
######ターミナル(ストロングパラメーターでbinding.pry)
|
204
|
+
|
181
205
|
Started POST "/drinks" for ::1 at 2020-07-31 18:26:12 +0900
|
182
206
|
|
183
207
|
Processing by DrinksController#create as HTML
|
@@ -204,11 +228,9 @@
|
|
204
228
|
|
205
229
|
=> <ActionController::Parameters {"authenticity_token"=>"VAoRocMTjIxu0Gevi14AEd7xNI/gixhxsQMap7wqgEbquwRvw9RyHkux+4Wocsq1LYhQx2WmRDxcGH1F669pTA==", "drink"=><ActionController::Parameters {"name"=>"熱燗", "price"=>"500円", "comment"=>"冬"} permitted: false>, "commit"=>"更新", "controller"=>"drinks", "action"=>"create"} permitted: false>
|
206
230
|
|
207
|
-
|
208
|
-
|
209
|
-
```
|
231
|
+
```
|
210
|
-
|
232
|
+
|
211
|
-
######
|
233
|
+
######ストロングパラメーターでbinding.pry
|
212
234
|
|
213
235
|
```
|
214
236
|
|
@@ -240,7 +262,29 @@
|
|
240
262
|
|
241
263
|
[2] pry(#<DrinksController>)>
|
242
264
|
|
243
|
-
|
265
|
+
```
|
266
|
+
|
267
|
+
######ターミナル(binding.pryせずnewアクションを実行)
|
268
|
+
|
269
|
+
```
|
270
|
+
|
271
|
+
Started POST "/drinks" for ::1 at 2020-07-31 20:43:53 +0900
|
272
|
+
|
273
|
+
Processing by DrinksController#create as HTML
|
274
|
+
|
275
|
+
Parameters: {"authenticity_token"=>"YyS7wjbf32ZE20LJX4EZrDJPQ7LntFQJs8EjEyFIinjdla4MNhgh9GG63uN8rdMIwTYn+mKZCERe2kTxds1jcg==", "drink"=>{"name"=>"熱燗", "price"=>"500円", "comment"=>"冬"}, "commit"=>"更新"}
|
276
|
+
|
277
|
+
Rendering drinks/create.html.haml within layouts/application
|
278
|
+
|
279
|
+
Rendered drinks/create.html.haml within layouts/application (Duration: 0.3ms | Allocations: 38)
|
280
|
+
|
281
|
+
[Webpacker] Everything's up-to-date. Nothing to do
|
282
|
+
|
283
|
+
Restaurant Load (0.5ms) SELECT `restaurants`.* FROM `restaurants` WHERE `restaurants`.`id` = 1 ORDER BY `restaurants`.`id` ASC LIMIT 1
|
284
|
+
|
285
|
+
↳ app/views/layouts/application.html.haml:17
|
286
|
+
|
287
|
+
Completed 200 OK in 55ms (Views: 50.8ms | ActiveRecord: 0.5ms | Allocations: 32668)
|
244
288
|
|
245
289
|
```
|
246
290
|
|
1
モデルファイルの記述を追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -142,6 +142,34 @@
|
|
142
142
|
|
143
143
|
```
|
144
144
|
|
145
|
+
###追記
|
146
|
+
|
147
|
+
######モデル(drink.rb)
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
class ApplicationRecord < ActiveRecord::Base
|
152
|
+
|
153
|
+
self.abstract_class = true
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
######モデル(application.record.rb)
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
class ApplicationRecord < ActiveRecord::Base
|
164
|
+
|
165
|
+
self.abstract_class = true
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
|
172
|
+
|
145
173
|
### 試したこと
|
146
174
|
|
147
175
|
binding.pryでデータが送られているか確認しました
|