Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render with non-200 status causing no layout and double loading of JS #348

Closed
kleinjm opened this issue Jun 15, 2022 · 2 comments
Closed

Comments

@kleinjm
Copy link

kleinjm commented Jun 15, 2022

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.

  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.

image
(no formatting or layout)

image

Workarounds

There is no issue when,

  1. Removing import "@hotwired/turbo-rails"; in my JS pack file
  2. Removing status: :forbidden from the render call

Neither of these workarounds are acceptable long term.

@dhh
Copy link
Member

dhh commented Jun 19, 2022

Fixed in Turbo head via hotwired/turbo#483.

@dhh dhh closed this as completed Jun 19, 2022
@kleinjm
Copy link
Author

kleinjm commented Jun 21, 2022

I'm still seeing the issue after installing from that specific sha but will wait until the next official release and reopen if necessary. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants