Ruby on Rails Wicked PDF 模板丢失错误

发布于 01-17 02:18 字数 312 浏览 2 评论 0原文

我目前正在使用 Rails 7 和 wicked pdf 。即使我在确切的位置有模板文件,邪恶的 pdf 也会给我一个丢失模板的错误?我做错了什么?

  def show
   respond_to do |format|
    format.html
    format.pdf do
     render pdf: "file_name", template: "stocks/pdf.html.erb"
    end
   end
 end

我做错了什么? 如果重要的话,我将 tailwindcss 与 jsbuild 一起使用。

I am currently using rails 7 with wicked pdf . wicked pdf is throwing me an missing template error even if I have template file at exact place? what am i doing wrong?

  def show
   respond_to do |format|
    format.html
    format.pdf do
     render pdf: "file_name", template: "stocks/pdf.html.erb"
    end
   end
 end

what am i doing wrong ?
I am using tailwindcss with jsbuild if that matters.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滥情稳全场2025-01-24 02:18:54

如果您的模板是 stocks/pdf.html.erb,您的渲染应如下所示:

format.pdf do
  render pdf: "file_name", template: "stocks/pdf", formats: [:html]
end

让我知道这是否适合您。

干杯

in case your template is stocks/pdf.html.erb, your render should be as following:

format.pdf do
  render pdf: "file_name", template: "stocks/pdf", formats: [:html]
end

Let me know if this works for you.

Cheers

吻安2025-01-24 02:18:54

就我而言,只有当我这样做时它才有效:

<%= link_to "File", data_path(data, format: :pdf) %>

在orders_controller中:

def data
   format.pdf do
      render pdf: "file_name", template: "orders/data", formats: [:html]
    end
end

文件位于“orders/data.html.erb”路径中

In my case, it worked only if I do:

<%= link_to "File", data_path(data, format: :pdf) %>

in orders_controller:

def data
   format.pdf do
      render pdf: "file_name", template: "orders/data", formats: [:html]
    end
end

The file is in "orders/data.html.erb" path

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文