Ruby on Rails InvalidAuthenticityToken Error (Solved)

Hi everyone, I am fairly new to Replit, and I was having some issues with my first Ruby on Rails application, and after much googling, I did not find a single answer to this question that worked without trying to circumvent Rails’ built in security. I kept getting a “ActionController::InvalidAuthenticityToken” error, and could not for the life of me figure out why. Every post I saw on google was telling me to just disable it completely, but I know what I don’t know, and I don’t know squat about security in programs, so I figured it was best to not just disable something all willy-nilly.

Turns out, the reason I was getting this error was because I was trying to test the application in Replit’s “Webview”, which is a great tool, but it was not properly accessing/storing/doing whatever it needed to with the authenticity token.

So if you are like me, and had this issue, a good step to add in your debugging process would be to open the Replit to a new tab either via clicking “New Tab” in the webview, or open the “Networking” tool and copy the link to a new tab/page.

Please delete/move if this does not belong here, just trying to help anyone that might have had the same problem as me.

1 Like