在Wicked_pdf中使用Activestorage映像
我无法获得激活图像来生产。我想在我生成的PDF主体内使用调整大小的图像(变体)。
= image_tag(@post.image.variant(resize_to_limit: [150, 100]))
它在开发中起作用,但是在生产生产中,PDF无限期地挂起,除非我将这条线排除在外。
我已经尝试了@post.image.variant(resize_to_limit:[150,100])。processed.url
和设置rails.application.default_url_options = {主机: “}
具有讽刺意味的是,当我重新启动乘客时,它将PDF发送到浏览器,实际上看起来不错。包括图像。
这是类似的:
= wicked_pdf_image_tag(@post.image.variant(resize_to_limit: [150, 100]).processed.url)
Rails 7.0.3,Ruby 3.1.2,Wicked_pdf 2.6.3
I can't get ActiveStorage images to work in production. I want to use a resized image (variant) within the body of the PDF I'm generating.
= image_tag(@post.image.variant(resize_to_limit: [150, 100]))
It worked in development but in production generating the PDF hangs indefinitely unless I take that line out.
I've tried things like @post.image.variant(resize_to_limit: [150, 100]).processed.url
and setting Rails.application.default_url_options = { host: "example.com" }
Ironically when I restart Passenger it sends the PDF to the browser and it actually looks fine. The image is included.
This is similar:
= wicked_pdf_image_tag(@post.image.variant(resize_to_limit: [150, 100]).processed.url)
Rails 7.0.3, Ruby 3.1.2, wicked_pdf 2.6.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多亏了@unixmonkey,我添加了passenger_min_instances 3;到我的服务器块中的NGINX配置中,它最初起作用,但会在负载下悬挂乘客。由于我没有提高该数字时投掷的RAM,因此我根据文件的读取图像提出了另一种解决方案。
然后,我在application_helper.rb中创建了一个助手,
我将其硬编码为PNG文件,因为这就是我所需要的。仅适用于磁盘存储。欢迎改进
Thanks to @Unixmonkey I added passenger_min_instances 3; to my server block in Nginx config and it worked initially but would hang Passenger under load. Since I didn't have the RAM to throw at increasing that number I came up with a different solution based on reading images from file.
Then I created a helper in application_helper.rb
I've hard coded it for PNG files as that's all I needed. Only works for Disk storage. Would welcome improvements