当用曲别针和S3在Heroku上上传模型缺少必需的attr_accessor为“photo_file_name” [英] model missing required attr_accessor for 'photo_file_name' when uploading with paperclip and S3 on heroku

查看:252
本文介绍了当用曲别针和S3在Heroku上上传模型缺少必需的attr_accessor为“photo_file_name”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的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

这确实使模型缺少photo_file_name错误消失要求attr_accessor,但它仍然无法正常工作。请参阅<一href="http://stackoverflow.com/questions/3575812/no-route-matches-with-paperclip-and-s3-on-heroku">my另一个问题,了解详细信息。正如我已经想通了,与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:分贝:迁移

heroku run rake:db:migrate

Heroku的重启

我已经做了我认为将完成同样的事情早已:

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

Heroku的耙分贝:模式:负载

heroku rake db:schema:load

但也许不工作或出事了这一进程。

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

这篇关于当用曲别针和S3在Heroku上上传模型缺少必需的attr_accessor为“photo_file_name”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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