質問編集履歴
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -157,3 +157,49 @@
|
|
157
157
|
```
|
158
158
|
|
159
159
|
初心者なので優しく答えていただけると嬉しいです。
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
追加
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
```indexメゾット
|
168
|
+
|
169
|
+
def index
|
170
|
+
|
171
|
+
page_size = 5
|
172
|
+
|
173
|
+
@page_num = 0
|
174
|
+
|
175
|
+
if params[:page] != nil then
|
176
|
+
|
177
|
+
@page_num = params[:page].to_i
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
@data = Blogpost.all.order('created_at desc')
|
182
|
+
|
183
|
+
.offset(page_size * @page_num)
|
184
|
+
|
185
|
+
.limit(page_size)
|
186
|
+
|
187
|
+
@blogconfig = Blogconfig.find 1
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
```ルーティング(blogs関係の部分)
|
196
|
+
|
197
|
+
root 'blogs#index'
|
198
|
+
|
199
|
+
get 'blog/index'
|
200
|
+
|
201
|
+
get 'blogs', to: 'blogs#index'
|
202
|
+
|
203
|
+
get 'blogs/:page', to: 'blogs#index'
|
204
|
+
|
205
|
+
```
|