I am developing an application with Rails 3.0.3.
I got "Can't dump file" error at the following code.
if @post.update_attributes params[:post]
redirect_to post_path(@post) #<= ERROR HERE
After googling, I added 2 lines to fix that.
if @post.update_attributes params[:post]
params[:post][:photos_attributes] = nil
params[:post][:attachments_attributes] = nil
redirect_to post_path(@post)
Now the error's gone. But I don't underst开发者_高级运维and why the error occurred and how it's fixed. I use active_record for the session store and it caused the error because a file can't be stored in DB. But why does redirect_to try to store file in the session?
Thanks.
Sam
Adding: ActiveRecord::SessionStore::Session.serializer = :json
to config/application.rb solved the issue for me.
I'm not sure what's in the photo_attributes
and attachment_attributes
. My guess is that they contain some sort of info on files and saving them is not working correctly.
Maybe you can post your Post
model for us to see?
I'm guessing attachment_attributes contains uploaded files.
Uploaded files are stored in params as ActionDispatch::Http::UploadedFile objects, and objects of this type are are not serialisable, hence the error.
精彩评论