I have a forbidden controller action that renders a page with a 403 response code.
def forbidden(exception)
@error_presenter = ErrorPresenter.new(status_code: :forbidden)
# ...
respond_to do |format|
format.html { render(:base_error, status: :forbidden) } # this is the line in question
format.all { head(:forbidden) }
end
end
Issue
When navigating from another page in my app to this forbidden page, the page renders without a layout and there are a series of JS errors related to double loading.
(no formatting or layout)
Workarounds
There is no issue when,
Removing import "@hotwired/turbo-rails"; in my JS pack file
Removing status: :forbidden from the render call
Neither of these workarounds are acceptable long term.
Context
Rails 7.0.2.4 Ruby 3.1.2 turbo-rails 1.1.1
I have a
forbidden
controller action that renders a page with a 403 response code.Issue
When navigating from another page in my app to this forbidden page, the page renders without a layout and there are a series of JS errors related to double loading.
(no formatting or layout)
Workarounds
There is no issue when,
import "@hotwired/turbo-rails";
in my JS pack filestatus: :forbidden
from therender
callNeither of these workarounds are acceptable long term.