This commit is contained in:
2025-07-11 02:05:16 +09:00
parent b83fc6369a
commit 3c89d14636
9 changed files with 191 additions and 66 deletions
+2 -6
View File
@@ -6,14 +6,10 @@ class PostsController < ApplicationController
# GET /posts
def index
limit = (params[:limit] || 20).to_i
cursor = params[:cursor]
cursor = params[:cursor].presence
q = filtered_posts.order(created_at: :desc)
next_cursor = nil
if cursor.present?
q = q.where('posts.created_at < ?', Time.iso8601(cursor))
end
q = q.where('posts.created_at < ?', Time.iso8601(cursor)) if cursor
posts = q.limit(limit + 1)