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

257
Visualizações
How do I force window.location.href to redirect as JS Rails 6

I have a controller create action called by a JS/ajax call.

Started POST "/some_domain/some_controller" for at Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by SomeController#create as JS

But when I try to send back a redirect to another controllers edit action using window.location.href, it rdirects as HTML. I want it to call the controller action as JS.

Controller

render js: "window.location.href =' #{edit_different_controller_path(@object.id)}'"

Started GET "/some_domain/different_controller/186/edit" for 115.70.22.192 at Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by DifferentController#edit as HTML

Thanks for any advice!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Add the format arg to the options of your url helper.

return redirect_to some_helper_url format: :js

It'll send back a url with the appropriate .js on the end.

about 4 years ago · Juan Pablo Isaza 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