我正在尝试在Active Storage中添加Signature Pad图像。但它一直都低于筹码。
ActiveSupport::MessageVerifier::InvalidSignature
我的表单很简单
<%= f.input_field :engineer_signature, as: :hidden, class: 'signature_pad_input' %>
<div class="signature_pad text-center">
<div class="signature_pad_body">
<canvas></canvas>
</div>
<div class="signature_pad_footer">
<div class="text-muted">Sign above</div>
<button type="button" class="btn btn-default signature_pad_clear">Clear</button>
<%= f.button :submit, 'Save', class: 'btn btn-success signature_pad_save' %>
</div>
</div>
Javascript文件是
$(document).ready(function() {
var canvas = document.querySelector("canvas");
if (canvas){
canvas.height = canvas.offsetHeight;
canvas.width = canvas.offsetWidth;
window.onresize = resizeCanvas(canvas);
resizeCanvas(canvas);
signature_pad = new SignaturePad(canvas);
$('.signature_pad_clear').click(function() {
signature_pad.clear(); console.log("SignaturePad Cleared"); });
$('.signature_pad_save').click(function(event) {
if (signature_pad.isEmpty()){
alert('Firma Electronica requerida antes de proceder');
event.preventDefault();
} else {
$('.signature_pad_input').val(signature_pad.toDataURL());
}
});
}
});
有帮助吗?