Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

634
Visualizações
Turbo-Rails with Devise does not redirect Consistently Rails 6.1.3 Devise 4.7.3 Turbo Rails 0.5.9

THIS IS A COMPANION TO https://github.com/hotwired/turbo-rails/issues/122

REPRODUCTION APP CODE: https://github.com/jasonfb/TR001

Using Rails 6.1.3

Devise 4.7.3

Turbo Rails 0.5.9


Symptom 1:
-- using Turbo-Rails + Devise

When I click "Log In", the form submits but the page does not reload.

Step 1: go to

/users/sign_in

Enter a good username & password (you can sign up or make one on the command line)

enter image description here

Click "Sign In"

enter image description here

on the back end the request WAS processed and even redirected, but the redirect did not happen on the front end. You (the user) ARE actually logged in even though your page is hanging and did not redirect.

enter image description here

Result: Page hangs. Expected result: Turbo Rails redirect correctly


Symptom 2

When I click "Log Out", the page does nothing. on the backend I am actually logged out, but the page does not change. If I reload, I see that I am now logged out

Step 1: be logged in

Step 2: Click to "log out" enter image description here

Notice that the button stays 'grey' (clicked), the request is processed on the back end:

enter image description here

Result: Page hangs

Expected result: Page directs after the user is logged out

The user IS ACTUALLY logged out, but the page hangs and does not redirect.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This has been fixed on the Devise main branch, but as of 2021-12-29 there is not a released version of Devise for Rails 7. If you want to use the latest main branch of Devise from Github, this problem should not affect you.

TEMPORARY WORKAROUND:

override the devise form (use rails generate devise:views generating your own custom views

then you will edit the registrations/new and sessions/new modifying both like so:

form_for(resource, as: resource_name, url: session_path(resource_name) ) do |f|

change it to

form_for(resource, as: resource_name, html: {'data-turbo' => "false"}, url: session_path(resource_name) ) do |f|

this tells Devise to fall back to non-Turbo interaction for the log-in and registration.

For your Logout links use Rails button_to instead of link_to and the symptom goes away. note: recommend as a temporary fix until the root cause is addressed

Again, button_to for LOGGING OUT must be like so:

, method: :delete, 'data-turbo': false

alternatively, a nested syntax like data: { turbo: false } should also work for either form_for or button_to

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda