CarrierWave 在 Rails 3.1 生产中无法渲染图片

发布于 2025-01-07 00:06:17 字数 421 浏览 4 评论 0原文

由于某种原因,我使用 Carrierwave 上传的图片没有显示在应用程序上。仅当我尝试在生产中部署应用程序时才会发生这种情况。我将我的商店目录配置为如下所示:

def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

在我的 html 源文件中,我看到它正在访问来自的图像

/uploads/picture/image/1/thumb_mango.jpg

但是,我发现在生产时该图片丢失了。在开发过程中,它渲染的图片效果很好。图片存储在“公共”文件夹内。所以路径会是这样的:

/public/uploads/...

For some reason, the picture that I upload using carrierwave is not showing up on the app. This only happens when I try to deploy the app in production. I configured my store directory to be like this:

def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

And in my html source file, I see that it is accessing the image from

/uploads/picture/image/1/thumb_mango.jpg

However, I see that the picture is missing when it is on PRODUCTION. In development, it is rendering the picture just fine. The picture is stored inside the 'public' folder. So the path would be like:

/public/uploads/...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文