I’m creating a multi-part form in the style that Ryan Bates describes here:
http://railscasts.com/episodes/217-multistep-forms
http://asciicasts.com/episodes/217-multistep-forms (text-based version)
To summarize, I have one view (with a bunch of partials for each form step), and the form variables are stored in a session when the user clicks a next button and a different part of the form is displayed.
One of my form steps allows the user to upload several images via the Paperclip gem. The problem with that is that Rails is trying to upload the image data to the session, which is returning TypeError “can’t dump File”.
What is a good way to go about this?
UPDATE:
I’ve tried a bunch of gems (wizardly, acts_as_wizard, and some other smaller ones) but none of them seem to work with Rails 3.
I’ve also tried just storing the data in an array until the form is complete, but that was causing my controller to get huge and messy.
Saving models into the session is working unless you want to save a
Fileinto the session. The wizard plugins are using the session to store models between the steps. They do not produce errors on valid models in my case only on invalids.So clearing out the attached file sounded a good idea, but in my case clearing out the paperclip attachment with
Attachment#clearwas not enough because it still wanted to save someFile.I’ve found out that the problem was with the
@queued_for_writeattribute inAttachmentwhich still contained the data.So the following two lines solved my problem:
This was a paperclip bug and was corrected in this commit.