Retrospring/app/controllers/question_controller.rb

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

20 lines
690 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-12-07 11:51:44 -08:00
class QuestionController < ApplicationController
2023-02-16 15:35:03 -08:00
include PaginatesAnswers
2014-12-07 11:51:44 -08:00
def show
@question = Question.find(params[:id])
@answers = @question.cursored_answers(last_id: params[:last_id], current_user:)
2023-02-16 14:51:38 -08:00
answer_ids = @answers.map(&:id)
@answers_last_id = answer_ids.min
@more_data_available = !@question.cursored_answers(last_id: @answers_last_id, size: 1, current_user:).count.zero?
2023-02-16 14:51:38 -08:00
@subscribed = Subscription.where(user: current_user, answer_id: answer_ids).pluck(:answer_id) if user_signed_in?
2015-01-03 10:24:51 -08:00
respond_to do |format|
2023-03-19 08:00:15 -07:00
format.html
format.turbo_stream { render layout: false, status: :see_other }
2015-01-03 10:24:51 -08:00
end
2014-12-07 11:51:44 -08:00
end
end