Using Rails 5.2 rc1, is it possible to do direct uploads on localhost in development?
This is my form new.html.erb
:
<div class="form-group">
<%= f.label :images %>
<%= f.file_field :images, multiple: true, direct_upload: true, class: 'form-control' %>
</div>
and this is the error I get in console:
ActiveSupport::MessageVerifier::InvalidSignature (ActiveSupport::MessageVerifier::InvalidSignature):
For anyone else bumping into this in the future:
I was mistakenly using this in my controller:
def create
@post = Post.new(post_params)
@post.images.attach(post_params[:images]) # THIS WAS THE ERROR!!!
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end
Creating a new post and attaching images which are already attached caused all sorts of errors like broken PG keys and invalid signatures.
Make sure you omit attach
when you upload files on a newly created model instance.