After updating a record, I use a turbo stream to send out some new command buttons to all users involved in that topic. It is a button_to in this case.
When I click on the button, I get the error ActionController::InvalidAuthenticityToken and get logged out. Everything works fine, if I load the modal by clicking on the record in the list items.
If anyone has any ideas about what could be going wrong, I am all ears.
button_to rails helper creates a form, which includes a unique authenticity token (hidden form field) linked to the users session. It’s likely the created button_to contains a hidden field with an authenticity token not valid for the current session you are testing.
# config/importmap.rb
pin "mrujs", to: "https://ga.jspm.io/npm:mrujs@0.7.1/dist/mrujs.module.js"
pin "morphdom", to: "https://ga.jspm.io/npm:morphdom@2.6.1/dist/morphdom.js"
It works well the first time a user is logged in through Devise. Though if the user unlog and relog, then the above code no longer works.
(edit: there is no HTML form in the front end, basically I gather HTML elements ID, that can be dragged with Shopify’s Draggable.js and ask the backend to save new order)
I have watched the Authenticity Token in head, and as expected for an SPA, it doesn’t change across Devise logins / log outs. But why does the backend expects a different token at some point ?