Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda