【问题标题】:Wicked_PDF changing filename according to idWicked_PDF 根据 id 更改文件名
【发布时间】:2011-10-04 15:55:43
【问题描述】:

我在 rails3 中使用 wicked_pdf。生成pdf或保存它们没问题。我唯一的问题是我想根据@post.id 动态命名文件。当我输入以下代码时,我的文件被命名为#{@post.id}。我究竟做错了什么。谢谢

def show
@post = Post.find(params[:id])
render :pdf => '#{@post.id}',
:layout => 'layouts/layout1.html.erb',
:template => 'posts/show.html.erb',

:save_to_file => Rails.root.join('public','pdfs', '#{@post.id}' + ".pdf")
end

【问题讨论】:

    标签: ruby-on-rails wicked-pdf


    【解决方案1】:

    仅当您使用双引号时,插值才有效。

    只需 "#{@post.id}" 就可以了

    【讨论】:

      猜你喜欢
      • 2012-08-19
      • 1970-01-01
      • 1970-01-01
      • 2015-03-24
      • 1970-01-01
      • 2022-08-19
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多