Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!