Syl*_*Syl 16 pdf templates ruby-on-rails wicked-pdf
我安装了邪恶的PDF并修改了我的控制器:
def show
respond_to do |format|
format.pdf do
render :pdf => "file_name"
end
format.html
end
end
Run Code Online (Sandbox Code Playgroud)
以下是我如何链接到pdf: compte_contrat_path(c,:format=>'pdf')
它适用于html(没有格式)但对于PDF失败,出现以下错误:
模板丢失了
Missing template contrats/show with {:locale=>[:fr], :formats=>[:pdf], :handlers=>[:erb, :builder, :coffee, :arb]}. Searched in:* "/home/sylario/ruby/place_de_marche/app/views"* "/usr/local/rvm/gems/ruby-1.9.2-p136/gems/activeadmin-0.5.0/app/views" *"/usr/local/rvm/gems/ruby-1.9.2-p136/gems/kaminari-0.14.1/app/views"*"/usr/local/rvm/gems/ruby-1.9.2-p136/gems/devise-2.2.0/app/views"
What am I doing wrong?
Syl*_*Syl 31
多亏亨利,我现在知道它与再培训局的格式有关.我找到了一种重用我的html.erb文件的方法:
首先,我在控制器中执行以下操作
format.pdf do
render :pdf => "file.pdf", :template => 'contrats/show.html.erb'
end
Run Code Online (Sandbox Code Playgroud)
然后,当我使用partials时,我称之为:
render :partial => 'fullpath/toview.html.erb', :formats => [:html], :locals => { :mylocal=>@something }
Run Code Online (Sandbox Code Playgroud)
drj*_*nco 11
对于 Rails 7,这是有效的:
format.pdf do
render pdf: "file_name", template: "posts/show", formats: [:html]
end
Run Code Online (Sandbox Code Playgroud)
请注意,模板不再具有 .html.erb 并且不要忘记包含“格式”。
| 归档时间: |
|
| 查看次数: |
7196 次 |
| 最近记录: |