質問するログイン新規登録

質問編集履歴

2

schemeを追加いたしました

2021/09/01 10:39

投稿

carp
carp

スコア27

title CHANGED
File without changes
body CHANGED
@@ -151,7 +151,7 @@
151
151
  ```
152
152
 
153
153
  ```
154
- sceme.rb)
154
+ scheme.rb)
155
155
 
156
156
  ActiveRecord::Schema.define(version: 2021_08_24_093957) do
157
157
 

1

sceme.rbとターミナルのエラー文を追加いたしました。

2021/09/01 10:39

投稿

carp
carp

スコア27

title CHANGED
File without changes
body CHANGED
@@ -148,4 +148,119 @@
148
148
  end
149
149
 
150
150
 
151
+ ```
152
+
153
+ ```
154
+ (sceme.rb)
155
+
156
+ ActiveRecord::Schema.define(version: 2021_08_24_093957) do
157
+
158
+ create_table "admins", force: :cascade do |t|
159
+ t.string "email", default: "", null: false
160
+ t.string "encrypted_password", default: "", null: false
161
+ t.string "reset_password_token"
162
+ t.datetime "reset_password_sent_at"
163
+ t.datetime "remember_created_at"
164
+ t.datetime "created_at", null: false
165
+ t.datetime "updated_at", null: false
166
+ t.boolean "is_deleted", default: false, null: false
167
+ t.index ["email"], name: "index_admins_on_email", unique: true
168
+ t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true
169
+ end
170
+
171
+ create_table "cart_items", force: :cascade do |t|
172
+ t.integer "quantity", default: 0
173
+ t.integer "item_id", null: false
174
+ t.integer "cart_id", null: false
175
+ t.datetime "created_at", null: false
176
+ t.datetime "updated_at", null: false
177
+ t.index ["cart_id"], name: "index_cart_items_on_cart_id"
178
+ t.index ["item_id"], name: "index_cart_items_on_item_id"
179
+ end
180
+
181
+ create_table "carts", force: :cascade do |t|
182
+ t.integer "carts_id"
183
+ t.integer "user_id"
184
+ t.datetime "created_at", null: false
185
+ t.datetime "updated_at", null: false
186
+ t.index ["carts_id"], name: "index_carts_on_carts_id"
187
+ t.index ["user_id"], name: "index_carts_on_user_id"
188
+ end
189
+
190
+ create_table "customers", force: :cascade do |t|
191
+ t.string "email", default: "", null: false
192
+ t.string "encrypted_password", default: "", null: false
193
+ t.string "reset_password_token"
194
+ t.datetime "reset_password_sent_at"
195
+ t.datetime "remember_created_at"
196
+ t.boolean "is_deleted", default: false, null: false
197
+ t.datetime "created_at", null: false
198
+ t.datetime "updated_at", null: false
199
+ t.index ["email"], name: "index_customers_on_email", unique: true
200
+ t.index ["reset_password_token"], name: "index_customers_on_reset_password_token", unique: true
201
+ end
202
+
203
+ create_table "items", force: :cascade do |t|
204
+ t.text "name"
205
+ t.integer "price"
206
+ t.integer "stock"
207
+ t.text "content"
208
+ t.string "image_id"
209
+ t.datetime "created_at", null: false
210
+ t.datetime "updated_at", null: false
211
+ t.integer "user_id"
212
+ end
213
+
214
+ create_table "order_items", force: :cascade do |t|
215
+ t.integer "item_id"
216
+ t.datetime "created_at", null: false
217
+ t.datetime "updated_at", null: false
218
+ t.index ["item_id"], name: "index_order_items_on_item_id"
219
+ end
220
+
221
+ create_table "orders", force: :cascade do |t|
222
+ t.integer "quantity"
223
+ t.integer "amount"
224
+ t.integer "item_id"
225
+ t.datetime "created_at", null: false
226
+ t.datetime "updated_at", null: false
227
+ t.index ["item_id"], name: "index_orders_on_item_id"
228
+ end
229
+
230
+ create_table "users", force: :cascade do |t|
231
+ t.string "email", default: "", null: false
232
+ t.string "encrypted_password", default: "", null: false
233
+ t.string "reset_password_token"
234
+ t.datetime "reset_password_sent_at"
235
+ t.datetime "remember_created_at"
236
+ t.string "name"
237
+ t.datetime "created_at", null: false
238
+ t.datetime "updated_at", null: false
239
+ t.boolean "is_deleted", default: false, null: false
240
+ t.index ["email"], name: "index_users_on_email", unique: true
241
+ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
242
+ end
243
+
244
+ end
245
+
246
+ ```
247
+
248
+
249
+ ```
250
+ (ターミナル)
251
+
252
+ Started POST "/customers/add_item?item_id=1" for 123.222.108.21 at 2021-09-01 10:33:54 +0000
253
+ Cannot render console from 123.222.108.21! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
254
+ Processing by Customers::CartsController#add_item as HTML
255
+ Parameters: {"authenticity_token"=>"LfCjenx99V8mFKEGRCrvQWSDAx6VRxtGcalkvgmrJdRcy1VDvzZ+2LtqD8YT46EGcm6fqCiAhevk5Wu50JPsjA==", "item_id"=>"1"}
256
+ Customer Load (0.1ms) SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? ORDER BY "customers"."id" ASC LIMIT ? [["id", 4], ["LIMIT", 1]]
257
+ ↳ app/controllers/application_controller.rb:8
258
+ Completed 500 Internal Server Error in 8ms (ActiveRecord: 0.1ms)
259
+
260
+
261
+
262
+ NoMethodError (undefined method `cart' for #<Customer:0x00007fb725049488>):
263
+
264
+ app/controllers/application_controller.rb:10:in `current_cart'
265
+ app/controllers/customers/carts_controller.rb:46:in `setup_cart_item!'
151
266
  ```