I have this controller action:
def attach_image
if @post.images.attach params[:image]
# success response
else
# unprocessable entity
end
end
And this is the code in the model:
class Post < ApplicationRecord
has_many_attached :images do |attachable|
attachable.variant :medium, resize_to_fit: [800, 1600]
end
validates :images, processable_image: true, content_type: ['image/png', 'image/jpeg'], size: { less_than: 10.megabytes }
The code works properly, however in production logs I find some errors like this:
ActiveSupport::MessageVerifier::InvalidSignature (mismatched digest):
app/controllers/posts_controller.rb:33:in `attach_image'
I cannot reproduce the issue, so I don’t know what is causing that strange exception for some uploads…
Any idea?