未定义的方法“image_will_change!”适用于 Heroku 上的 CarrierWave
我有一个安装 Carrierwave 上传器的简单模型。开发中一切正常,但我得到一个未定义的方法“image_will_change!” Heroku 上的错误。
class Receipt < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
class ImageUploader < CarrierWave::Uploader::Base
storage :fog
def store_dir
"receipts/saved"
end
end
我也根据 Carrierwave Wiki 正确设置了 cache_dir 。
receipt.image = File.open "public/images/test.jpg" #works fine in development, fails in heroku
I have a simple model that mounts a Carrierwave uploader. Everything works fine in development, but I get an undefined method "image_will_change!" error on heroku.
class Receipt < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
class ImageUploader < CarrierWave::Uploader::Base
storage :fog
def store_dir
"receipts/saved"
end
end
I have the cache_dir set appropriately as well according to the Carrierwave Wiki.
receipt.image = File.open "public/images/test.jpg" #works fine in development, fails in heroku
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 Heroku 上的数据库很可能在收据表中没有图像列。
It's likely that your db on heroku doesn't have the image column in the receipts table.
即使在heroku上运行迁移后,错误仍然存在。
我发现需要使用 heroku restart 命令才能永远消除该错误。
Even after running the migration on heroku, the error persisted.
I found that a heroku restart command was required to vanquish the error forever.
这可能是因为你忘记运行:
It's probably because you forgot to run: