retrospring/app/models/user/answer_methods.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
410 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module User::AnswerMethods
include CursorPaginatable
define_cursor_paginator :cursored_answers, :ordered_answers
2023-01-28 21:17:08 +01:00
# @return [ActiveRecord::Relation<Answer>] List of a user's answers
def ordered_answers(current_user_id:)
answers
.for_user(current_user_id)
.order(:created_at)
.reverse_order
2023-10-22 21:51:21 +02:00
.includes(question: { user: [:profile] })
end
end