无法在 rails 中转储文件错误 [英] Can't dump file error in rails

查看:40
本文介绍了无法在 rails 中转储文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Rails 3.0.3 开发应用程序.

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

谷歌搜索后,我添加了 2 行来解决这个问题.

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)

现在错误消失了.但我不明白为什么会发生错误以及它是如何修复的.我将 active_record 用于会话存储,它导致错误,因为文件无法存储在 DB 中.但是为什么redirect_to 尝试在会话中存储文件?

Now the error's gone. But I don't understand 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?

谢谢.

山姆

推荐答案

添加:ActiveRecord::SessionStore::Session.serializer = :json 到 config/application.rb 为我解决了这个问题.

Adding: ActiveRecord::SessionStore::Session.serializer = :json to config/application.rb solved the issue for me.

这篇关于无法在 rails 中转储文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆