質問編集履歴

3

エラー内容が変更されたので修正しました

2019/02/24 02:10

投稿

begenner
begenner

スコア79

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ```bash
14
14
 
15
- NoMethodError: undefined method `created_at'
15
+ NoMethodError: undefined method `created_at' for nil:NilClass
16
16
 
17
17
  ```
18
18
 

2

コードを編集しました

2019/02/24 02:10

投稿

begenner
begenner

スコア79

test CHANGED
File without changes
test CHANGED
@@ -80,7 +80,7 @@
80
80
 
81
81
  # カート商品の作成
82
82
 
83
- 1.upto(user_count) do |i|
83
+ user_count.times do |i|
84
84
 
85
85
 
86
86
 
@@ -94,9 +94,9 @@
94
94
 
95
95
  order_id: nil,
96
96
 
97
- created_at: users[i].created_at + 10 * 60,
97
+ created_at: users[i + 1].created_at + 10 * 60,
98
98
 
99
- updated_at: users[i].created_at + 10 * 60
99
+ updated_at: users[i + 1].created_at + 10 * 60
100
100
 
101
101
  )
102
102
 

1

変数の宣言を追加しました

2019/02/24 01:40

投稿

begenner
begenner

スコア79

test CHANGED
File without changes
test CHANGED
@@ -72,6 +72,12 @@
72
72
 
73
73
 
74
74
 
75
+ # 別で作成してあります
76
+
77
+ item_count = 100
78
+
79
+
80
+
75
81
  # カート商品の作成
76
82
 
77
83
  1.upto(user_count) do |i|