5

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?

atmorell
  • 3,052
  • 6
  • 30
  • 44

3 Answers3

3

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.

Ariejan
  • 10,910
  • 6
  • 43
  • 40
0

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

Community
  • 1
  • 1
tamersalama
  • 4,093
  • 1
  • 32
  • 35
0

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

ebsbk
  • 4,512
  • 3
  • 24
  • 29
  • 1
    Cached version of the article: http://web.archive.org/web/20100919151143/http://ryantownsend.co.uk/articles/storing-paperclip-file-uploads-when-validation-fails.html – ebsbk Jul 09 '12 at 13:22