如果没有
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
错误。
我完全遵循了这个指南:
https://guides.rubyonrails.org/active_storage_overview.html#direct-uploads
application_controller.rb
skip_before_action :verify_authenticity_token
只有当我
direct_upload: true
这是我的表格:
<%= 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 %>