RoR InvalidAuthenticityToken with Active Storage direct upload

RoR InvalidAuthenticityToken with Active Storage direct upload

I am trying to use rails active storage to directly upload to an Amazon s3 bucket. However, let's treat this as directly uploading when the storage medium is the local disk, because I can't get that to work either.

I am trying to use rails active storage to directly upload to an Amazon s3 bucket. However, let's treat this as directly uploading when the storage medium is the local disk, because I can't get that to work either.

I am unable to do this without ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):

errors.

I have followed this guide exactly: https://guides.rubyonrails.org/active_storage_overview.html#direct-uploads

I have even gone so far as to disable csrf application wide with this line of code in my application_controller.rb skip_before_action :verify_authenticity_token

This only happens when I have direct_upload: true in my form.

Here is my form:

<%= form_with url: messages_path do |form| %>

<%= form.label 'Upload' %>

<%= form.file_field :audio_message, class: 'form-control', direct_upload: true, :required => true%>

<%= form.submit 'Upload file', class: 'form-control' %>

<% end %>

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Ruby on Rails vs PHP

Understanding the pros and cons of Ruby on Rails versus PHP is important when deciding how to create your business-critical applications.