在heroku上使用回形针和S3上传时,模型缺少“photo_file_name"所需的attr_accessor [英] model missing required attr_accessor for 'photo_file_name' when uploading with paperclip and S3 on heroku

查看:15
本文介绍了在heroku上使用回形针和S3上传时,模型缺少“photo_file_name"所需的attr_accessor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 linux 开发环境中使用 S3 设置回形针非常容易——一切都是开箱即用的.但是,我无法让它在 Heroku 上运行.

Setting up paperclip with S3 in my linux dev environment was a snap -- everything works out of the box. However, I can't get it to work on Heroku.

当我尝试上传时,日志显示:

When I try to do an upload, the log shows:

Processing ItemsController#create (for 72.177.97.9 at 2010-08-26 16:35:14) [POST]  
  Parameters: {"commit"=>"Create", "authenticity_token"=>"0Hy3qvQBHE1gvFVaq32HMy2ZIopelV0BHbrSeHkO1Qw=", "item"=>{"photo"=>#<File:/home/slugs/270862_4aa601b_4b6f/mnt/tmp/RackMultipart20100826-6286-1256pvc-0>, "price"=>"342", "name"=>"a new item", "description"=>"a new item", "sold"=>"0"}}

Paperclip::PaperclipError (Item model missing required attr_accessor for 'photo_file_name'):

我发现了一篇引用此错误的博客文章,并说要将其添加到我的模型中:

I found one blog post that referenced this error, and it said to add this to my model:

attr_accessor :photo_file_name
attr_accessor :photo_content_type
attr_accessor :photo_file_size
attr_accessor :photo_updated_at

这确实使 model missing required attr_accessor for 'photo_file_name' 错误消失,但它仍然不起作用.有关详细信息,请参阅我的其他问题.我已经发现,将 attr_accessor 行添加到我的模型后,即使在我的开发系统上上传也会失败,我怀疑这不是正确的答案.

That does indeed make the model missing required attr_accessor for 'photo_file_name' error go away, but it still doesn't work. See my other question for details. As I have figured out that with the attr_accessor lines added to my model the uploads fail even on my dev system, I suspect that is not the right answer.

推荐答案

发现问题:需要更新数据库.

Found the problem: needed to update the database.

heroku 运行 rake:db:migrate

heroku run rake:db:migrate

heroku 重启

我已经做了我认为已经完成的事情:

I had done what I thought would have accomplished the same thing already:

heroku rake db:schema:load

heroku rake db:schema:load

但也许这不起作用或过程中出现问题.

but perhaps that doesn't work or something went wrong in the process.

这篇关于在heroku上使用回形针和S3上传时,模型缺少“photo_file_name"所需的attr_accessor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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