Setup turbo_stream_actions before before_actions

Because apparently the error catching -> toast logic was not there yet and people might run into a 500 error redirect when pressing the button.
This commit is contained in:
Andreas Nedbal 2025-02-21 22:06:52 +01:00 committed by Andreas Nedbal
parent 02db8e1a56
commit 4408de33cc
4 changed files with 9 additions and 9 deletions

View file

@ -1,13 +1,13 @@
# frozen_string_literal: true # frozen_string_literal: true
class AnswerController < ApplicationController class AnswerController < ApplicationController
before_action :authenticate_user!, only: %i[pin unpin]
before_action :not_readonly!, except: %i[show]
include TurboStreamable include TurboStreamable
turbo_stream_actions :pin, :unpin turbo_stream_actions :pin, :unpin
before_action :authenticate_user!, only: %i[pin unpin]
before_action :not_readonly!, except: %i[show]
def show def show
@answer = Answer.for_user(current_user).includes(question: [:user], smiles: [:user]).find(params[:id]) @answer = Answer.for_user(current_user).includes(question: [:user], smiles: [:user]).find(params[:id])
@display_all = true @display_all = true

View file

@ -3,11 +3,11 @@
class ReactionsController < ApplicationController class ReactionsController < ApplicationController
include TurboStreamable include TurboStreamable
turbo_stream_actions :create, :destroy
before_action :authenticate_user!, only: %w[create destroy] before_action :authenticate_user!, only: %w[create destroy]
before_action :not_readonly!, except: %i[index] before_action :not_readonly!, except: %i[index]
turbo_stream_actions :create, :destroy
def index def index
answer = Answer.includes([smiles: { user: :profile }]).find(params[:id]) answer = Answer.includes([smiles: { user: :profile }]).find(params[:id])

View file

@ -3,11 +3,11 @@
class RelationshipsController < ApplicationController class RelationshipsController < ApplicationController
include TurboStreamable include TurboStreamable
turbo_stream_actions :create, :destroy
before_action :authenticate_user! before_action :authenticate_user!
before_action :not_readonly! before_action :not_readonly!
turbo_stream_actions :create, :destroy
def create def create
params.require :screen_name params.require :screen_name

View file

@ -3,11 +3,11 @@
class SubscriptionsController < ApplicationController class SubscriptionsController < ApplicationController
include TurboStreamable include TurboStreamable
turbo_stream_actions :create, :destroy
before_action :authenticate_user! before_action :authenticate_user!
before_action :not_readonly! before_action :not_readonly!
turbo_stream_actions :create, :destroy
def create def create
answer = Answer.find(params[:answer]) answer = Answer.find(params[:answer])
result = Subscription.subscribe(current_user, answer) result = Subscription.subscribe(current_user, answer)