Results 1 to 1 of 1
Thread: paperclip and file upload issue
Feb 1, 2014, 04:05 #1
- Join Date
- Apr 2013
- 0 Post(s)
- 0 Thread(s)
paperclip and file upload issue
I have a multi-step form inspired by this railcast that has 3 file upload images. However when I upload an image I receive an error can't dump File.
From searching in forums I saw posts saying that saving a file uploads in the session doesn't work so I need to use something like this:
unless @post.valid? @post.assets.first.attachment.clear @post.assets.first.attachment.queued_for_write.clear end
This however doesn't seem to work. Should I look through the three file uploads and clear them every time? How can I avoid this error?
Here is my create function from my controller:
session[:post_params].deep_merge!(params[:post]) if params[:post] session[:duration] = params[:post_duration] if params[:post_duration] @post = Post.new(session[:post_params]) @post.current_step = session[:post_step] unless @post.valid? logger.info("attachment " + @post.assets.first.attachment.inspect) @post.assets.first.attachment.clear @post.assets.first.attachment.queued_for_write.clear end if @post.valid? if params[:back_button] @post.previous_step elsif @post.last_step? if @post.all_valid? ... session[:post_step] = session[:post_params] = nil redirect_to @post and return end else @post.next_step end session[:post_step] = @post.current_step end if @post.new_record? render "new" end end
Thank you for reading.