Switch Teams bug on Safari?

Matt Bjornson
Is anyone else getting the error
``` ActionController::RoutingError (No route matches [GET] "/teams/1/switch"):
in Safari when a user switches teams? Works fine in chrome....
Chris Oliver
It's a PATCH request, not a GET. Sounds like Rails UJS isn't sending a PATCH for you in Safari.
Matt Bjornson
Thanks , this was hard to figure out... But this was the change that caused this to happen, but am not sure why.

safari bug

window.Rails = Rails

fixed bug
// window.Rails = Rails

What does window.Rails do?
Chris Oliver
It makes the Rails variable available on window like in your browser JS console, .js.erb responses, etc.

Safari is letting me switch teams just fine on this site which is running window.Rails = require("@rails/ujs") in production though.
Matt Bjornson
Thanks ! Is window.Rails variable required for new rails_ujs library to work? Is there a gorails episode on testing javascript :)
Chris Oliver
I can't remember for sure, but I think its required to use Rails in the js.erb responses.

System tests would be the way you'd test that so you get the full integration tested, not just the JS.
You’re not receiving notifications from this thread.
© 2022 Jumpstart Pro by GoRails, LLC