As it turns out, the development of documentation is quite indicative of this error:
For Rails 5, note that protect_from_forgery is no longer added to the before_action chain, so if you set authenticate_user before protect_from_forgery , your request will result in β Unable to authenticate CSRF token. β To solve this problem, change the order in which you call them or use protect_from_forgery prepend: true .
The fix was to change the code in my application controller from this:
protect_from_forgery with: :exception
On this:
protect_from_forgery prepend: true
This problem did not appear until I tried to add Audited or Paper Trail gems.
source share