質問編集履歴

1

追記

2019/12/03 14:32

投稿

tomtom1
tomtom1

スコア168

test CHANGED
File without changes
test CHANGED
@@ -10,11 +10,15 @@
10
10
 
11
11
 
12
12
 
13
+ ※諸々進みましたので、一番最初の質問から修正した最新状況に書き加えました。
14
+
13
15
  ###エラー
14
16
 
15
- **undefined method `next_page' for nil:NilClass**
17
+ なし
16
18
 
17
- ![](d4539c210d4bf6d5b2600de11dc74a4e.png)
19
+ Postが3つ表示されますが、Moreボタンを押しても、表示数は増えません。
20
+
21
+
18
22
 
19
23
 
20
24
 
@@ -72,10 +76,72 @@
72
76
 
73
77
  def index
74
78
 
75
- @items = Item.all.page(params[:page]).per(10).order(created_at: :desc)
79
+ @items = Item.all.page(params[:page]).order(created_at: :desc)
76
80
 
77
81
  end
78
82
 
79
83
  ```
80
84
 
85
+ ```Model
86
+
87
+ paginates_per 3
88
+
89
+ ```
90
+
91
+ Moreボタンを押した直後のログ
92
+
93
+ ```log
94
+
95
+ Started GET "/posts/index?page=2" for 127.0.0.1 at 2019-12-03 23:28:01 +0900
96
+
97
+ Processing by PostsController#index as JS
98
+
99
+ Parameters: {"page"=>"2"}
100
+
101
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
102
+
103
+ ↳ app/controllers/application_controller.rb:6
104
+
105
+ Rendering posts/index.html.erb within layouts/application
106
+
107
+ Post Load (0.4ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."created_at" DESC LIMIT ? OFFSET ? [["LIMIT", 3], ["OFFSET", 3]]
108
+
109
+ ↳ app/views/posts/_items.html.erb:1
110
+
111
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
112
+
113
+ ↳ app/models/post.rb:16
114
+
115
+ CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
116
+
117
+ ↳ app/models/post.rb:16
118
+
119
+ CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
120
+
121
+ ↳ app/models/post.rb:16
122
+
123
+ CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
124
+
125
+ ↳ app/models/post.rb:16
126
+
127
+ CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
128
+
129
+ ↳ app/models/post.rb:16
130
+
131
+ CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
132
+
133
+ ↳ app/models/post.rb:16
134
+
135
+ CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
136
+
137
+ ↳ app/models/post.rb:16
138
+
139
+ Rendered posts/_items.html.erb (14.6ms)
140
+
141
+ Rendered posts/index.html.erb within layouts/application (37.3ms)
142
+
143
+ Completed 200 OK in 129ms (Views: 100.7ms | ActiveRecord: 1.3ms)
144
+
145
+ ```
146
+
81
147
  お分かりの方宜しくお願い致します。