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!
CodePudding user response:
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.