From 14f32aa3c0ec105f5d9105383bf5ced9614c1b52 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sat, 21 Jan 2023 19:55:57 +0100 Subject: [PATCH] question: only provide #show as GET --- app/views/question/show.html.haml | 7 +++++-- app/views/question/show.turbo_stream.haml | 7 +++++-- config/routes.rb | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/views/question/show.html.haml b/app/views/question/show.html.haml index 746fb6c9..614a62e7 100644 --- a/app/views/question/show.html.haml +++ b/app/views/question/show.html.haml @@ -8,8 +8,11 @@ - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start#paginator - = button_to question_path(@question.user.screen_name, @question.id, last_id: @answers_last_id), class: "btn btn-light" do - = t("voc.load") + = button_to t("voc.load"), question_path(@question.user.screen_name, @question.id), + class: "btn btn-light", + method: :get, + params: { last_id: @answers_last_id }, + form: { data: { turbo_stream: true } } - if user_signed_in? && !current_user.answered?(@question) && current_user != @question.user && @question.user&.privacy_allow_stranger_answers .card#q-answer-box diff --git a/app/views/question/show.turbo_stream.haml b/app/views/question/show.turbo_stream.haml index 029b9127..9ef4eb64 100644 --- a/app/views/question/show.turbo_stream.haml +++ b/app/views/question/show.turbo_stream.haml @@ -4,5 +4,8 @@ = turbo_stream.update "paginator" do - if @more_data_available - = button_to question_path(@question.user.screen_name, @question.id, last_id: @answers_last_id), class: "btn btn-light" do - = t("voc.load") + = button_to t("voc.load"), question_path(@question.user.screen_name, @question.id), + class: "btn btn-light", + method: :get, + params: { last_id: @answers_last_id }, + form: { data: { turbo_stream: true } } diff --git a/config/routes.rb b/config/routes.rb index 0f7d6ec5..5a72b22d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -154,7 +154,7 @@ Rails.application.routes.draw do get "/user/:username(/p/:page)", to: "user#show", defaults: { page: 1 } get "/@:username(/p/:page)", to: "user#show", as: :user, defaults: { page: 1 } get "/@:username/a/:id", to: "answer#show", via: "get", as: :answer - match "/@:username/q/:id", to: "question#show", via: [:get, :post], as: :question + get "/@:username/q/:id", to: "question#show", as: :question get "/@:username/followers(/p/:page)", to: "user#followers", as: :show_user_followers, defaults: { page: 1 } get "/@:username/followings(/p/:page)", to: "user#followings", as: :show_user_followings, defaults: { page: 1 } get "/@:username/friends(/p/:page)", to: redirect("/@%{username}/followings/p/%{page}"), defaults: { page: 1 }