Skip to content

Commit 37461d2

Browse files
Disabled Turbo for the new and create action as it caused issues with CSRF verification for the new form
1 parent fce0ae6 commit 37461d2

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

app/controllers/distributions_controller.rb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class DistributionsController < ApplicationController
77
include DateRangeHelper
88
include DistributionHelper
99

10-
before_action :enable_turbo!, only: %i[new show]
10+
before_action :enable_turbo!, only: %i[show]
1111
skip_before_action :authenticate_user!, only: %i(calendar)
1212
skip_before_action :authorize_user, only: %i(calendar)
1313

@@ -101,11 +101,7 @@ def create
101101
perform_inventory_check
102102
schedule_reminder_email(result.distribution) if @distribution.reminder_email_enabled
103103

104-
respond_to do |format|
105-
format.turbo_stream do
106-
redirect_to distribution_path(result.distribution), notice: "Distribution created!"
107-
end
108-
end
104+
redirect_to distribution_path(result.distribution), notice: "Distribution created!"
109105
else
110106
@distribution = result.distribution
111107
if request_id
@@ -132,16 +128,8 @@ def create
132128
end
133129

134130
flash_error = insufficient_error_message(result.error.message)
135-
136-
respond_to do |format|
137-
format.turbo_stream do
138-
flash.now[:error] = flash_error
139-
render turbo_stream: [
140-
turbo_stream.replace(@distribution, partial: "form", locals: {distribution: @distribution, date_place_holder: @distribution.issued_at}),
141-
turbo_stream.replace("flash", partial: "shared/flash")
142-
], status: :bad_request
143-
end
144-
end
131+
flash.now[:error] = flash_error
132+
render :new
145133
end
146134
end
147135

0 commit comments

Comments
 (0)