質問編集履歴
2
コメント対応
test
CHANGED
File without changes
|
test
CHANGED
@@ -269,3 +269,277 @@
|
|
269
269
|
お力添え願います。不足した情報があればご指摘ください。
|
270
270
|
|
271
271
|
よろしくお願いいたします。
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
### 追記
|
276
|
+
|
277
|
+
ご指摘いただきましたので、追記いたします
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
_routes.rb
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
|
285
|
+
Rails.application.routes.draw do
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
#管理者
|
290
|
+
|
291
|
+
devise_for :admin, skip: [:registrations, :passwords] ,controllers: {
|
292
|
+
|
293
|
+
sessions: 'admin/sessions',
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
namespace :admin do
|
300
|
+
|
301
|
+
get 'admin/new', to: 'admin/sessions#new'
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
#items
|
306
|
+
|
307
|
+
resources :items, only:[:new, :show, :index, :edit, :create, :update]
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
#genres
|
312
|
+
|
313
|
+
resources :genres, only:[:index, :edit, :create, :update]
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
#customers
|
318
|
+
|
319
|
+
resources :customers, only:[:index, :edit, :show, :update]
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
#orders
|
324
|
+
|
325
|
+
resources :orders, only:[:index, :show, :update] do
|
326
|
+
|
327
|
+
#oder_items
|
328
|
+
|
329
|
+
resources :order_items, only:[:index, :update]
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
#会員
|
342
|
+
|
343
|
+
devise_for :customers,skip: [:passwords,], controllers: {
|
344
|
+
|
345
|
+
registrations: 'customers/registrations',
|
346
|
+
|
347
|
+
sessions: 'customers/sessions',
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
scope module: :public do
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
#homes
|
360
|
+
|
361
|
+
root 'homes#top'
|
362
|
+
|
363
|
+
get 'homes/about' => 'homes#about'
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
#items
|
368
|
+
|
369
|
+
resources :items, only:[:show, :index]
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
#cart_items
|
374
|
+
|
375
|
+
resources :cart_items, only:[:index, :create, :update, :destroy] do
|
376
|
+
|
377
|
+
collection do
|
378
|
+
|
379
|
+
delete 'cart_items/destroy_all' => 'cart_items#destroy_all'
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
#orders
|
388
|
+
|
389
|
+
resources :orders, only:[:new, :show, :index, :create] do
|
390
|
+
|
391
|
+
collection do
|
392
|
+
|
393
|
+
post 'orders/confirm' => 'orders#confirm'
|
394
|
+
|
395
|
+
get 'orders/complete' => 'orders#complete'
|
396
|
+
|
397
|
+
end
|
398
|
+
|
399
|
+
end
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
#customers
|
408
|
+
|
409
|
+
resources :customers, only:[:show, :edit, :update] do
|
410
|
+
|
411
|
+
collection do
|
412
|
+
|
413
|
+
get 'customers/leave' => 'customers#leave'
|
414
|
+
|
415
|
+
patch 'customers/out' => 'customers#out'
|
416
|
+
|
417
|
+
end
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
end
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
#deliveries
|
432
|
+
|
433
|
+
resources :deliveries, only:[:index, :create, :edit, :update, :destroy]
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
446
|
+
|
447
|
+
end
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
```
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
orders_controller
|
456
|
+
|
457
|
+
```ruby
|
458
|
+
|
459
|
+
class Admin::OrdersController < ApplicationController
|
460
|
+
|
461
|
+
before_action :authenticate_admin!
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
def index
|
466
|
+
|
467
|
+
@count = Order.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).count
|
468
|
+
|
469
|
+
@orders = Order.all.page(params[:page]).per(10)
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
case params[:order]
|
474
|
+
|
475
|
+
when 'today'
|
476
|
+
|
477
|
+
@orders = Order.page(params[:page]).where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).per(10) #ここまでできてる
|
478
|
+
|
479
|
+
when 'customer'
|
480
|
+
|
481
|
+
customer_id = Rails.application.routes.recognize_path(request.referer)[:id]
|
482
|
+
|
483
|
+
@customer = Customer.find(customer_id)
|
484
|
+
|
485
|
+
@orders = @customer.orders.page(params[:page]).per(10)
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
end
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
def show
|
494
|
+
|
495
|
+
@order = Order.find(params[:id])
|
496
|
+
|
497
|
+
@order_items = @order.order_items.all
|
498
|
+
|
499
|
+
end
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
end
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
def update
|
508
|
+
|
509
|
+
order = Order.find(params[:id])
|
510
|
+
|
511
|
+
order_items = order.order_items
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
# if order.update(order_params)
|
516
|
+
|
517
|
+
# redirect_to admin_order_path(order), notice:"注文ステータスを更新しました"#非同期通信導入検討
|
518
|
+
|
519
|
+
# else
|
520
|
+
|
521
|
+
# render :show, alert: "注文ステータスを更新できませんでした"
|
522
|
+
|
523
|
+
# end
|
524
|
+
|
525
|
+
end
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
private
|
532
|
+
|
533
|
+
def order_params
|
534
|
+
|
535
|
+
params.require(:order).permit(:order_status)
|
536
|
+
|
537
|
+
end
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
end
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
```
|
1
正しく保存されいなかったため
test
CHANGED
File without changes
|
test
CHANGED
@@ -264,6 +264,8 @@
|
|
264
264
|
|
265
265
|
|
266
266
|
|
267
|
-
ファイル
|
267
|
+
ファイルの階層等見直しましたが、原因がわかりませんでした。
|
268
|
+
|
268
|
-
|
269
|
+
お力添え願います。不足した情報があればご指摘ください。
|
270
|
+
|
269
|
-
|
271
|
+
よろしくお願いいたします。
|