Rails 3 Paperclip 和 S3 的路由错误
我完全按照本教程进行操作并收到了尝试将 JPG 上传到我的本地环境后出现以下错误(我还没有推送到 Heroku):
ActionController::RoutingError(否 路线匹配 “/logos/medium/missing.png”)
我检查了类似的教程,但没有一个提到需要远程图像的路由。就像我说的,我已经仔细检查了本教程,并且正在执行它要求我做的所有事情,那么我在这里可能会遗漏哪些步骤呢?唯一的区别是我已经在模型中将“照片”列指定为与 has_attached_file
变量同名的二进制数据类型......这可能会导致冲突吗?
I followed this tutorial exactly and received the following error after trying to upload a JPG to my local environment (I have not pushed to Heroku yet):
ActionController::RoutingError (No
route matches
"/logos/medium/missing.png")
I checked similar tutorials and none of them mentioned requiring routes for your remote images. Like I said, I have triple-checked this tutorial and I'm doing everything it asks of me, so what steps could I be missing here? The ONLY difference is that I already had specified a "photo" column in my model as a binary datatype with the same name as the has_attached_file
variable...could that be causing the conflict?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我意识到对其他人来说了解问题所在时很有价值时,我正打算删除此内容。
因此,如果您遵循该教程,您将会做得很好。但是,如果您使用 attr_accessible 来保护模型的属性,则需要在模型中指定所有属性,以使这些图像实际保存到您的 S3 存储桶中。
如果您在日志中看到以下内容,则会出现提示:
警告:无法批量分配受保护的属性:照片
这可以让您知道数据库中有需要通过以下方式公开的受保护列:
attr_accessible
如果您按照我在问题中提供的示例教程进行操作,代码将如下所示:
I was about to delete this when I realized it will be valuable for others to learn what went wrong.
So if you follow that tutorial to the tee you will do just fine. HOWEVER, if you use
attr_accessible
to protect the attributes of your model, you need to specify ALL of them in your model in order to make these images actually save to your S3 bucket.A hint will be if you see the following in your logs:
WARNING: Can't mass-assign protected attributes: photo
This lets you know that you have protected columns in your database that need to be exposed through
attr_accessible
Here's what the code would look like if you were to follow the example tutorial I provided in my question: