开发者

Paperclip and failed validation - avoid reupload

I am currently 开发者_运维问答setting up Paperclip for a model with Rails 3. When one of the fields fails validation (title), the user has to upload the file again. This is not very user friendly :/

The recommendation from the Paperclip forum is to move the Paperclip stuff into a related model. My model is very simple with just a few fields, so I would like to avoid having two pages/steps for creating a record.

arts/create (when valid) -> arts_image/create

Any suggestions?


I use the two-step solution with a separate model. Although it's possible to code and hack your way around the default behaviour, you could also validate on the client-side with JS.


Look at this article http://ryantownsend.co.uk/articles/storing-paperclip-file-uploads-when-validation-fails.html Cached version of the article: http://web.archive.org/web/20100919151143/http://ryantownsend.co.uk/articles/storing-paperclip-file-uploads-when-validation-fails.html


I have taken a different approach by 'serving' the file back to the client and re-accepting it when the form gets resubmitted.

https://stackoverflow.com/a/25853569/7693

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜