Rails 验证错误后如何保留文件上传字段 [英] How to persist file upload fields after a rails validation error

查看:27
本文介绍了Rails 验证错误后如何保留文件上传字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个文件上传的表单,问题是当我提交表单并发生验证错误时,文件输入字段被重置.

I have a form with multiple file uploads, The issue is when i am submitting the form and an validation error occurs, the file input field gets reset.

我基本上想将这些文件保存在文件输入字段中以完成整个过程.

I basically wanted to persist those files inside the file input field for the complete process.

我也浏览了几个链接

我该如何?保持"表单验证错误时上传的图片?

请让我知道在这种情况下可以遵循的各种选项是什么.

Please let me know what are the various options in such cases that one can follow.

推荐答案

Carrierwave 是处理文件上传的绝佳工具,可以为您处理此问题

Carrierwave is a great tool for handling file uploads and can handle this for you

https://github.com/jnicklas/carrierwave#making-uploads-work-across-form-redisplays

这篇关于Rails 验证错误后如何保留文件上传字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆