简体   繁体   English

带有大虾导轨的未定义方法`pdf`

[英]Undefined method `pdf` with prawn-rails

Trying to set up a basic PDF template with prawn-rails, and something's not quite right. 试图用虾栏设置一个基本的PDF模板,这不太正确。

Gemfile : 宝石文件

gem 'prawn-rails'

which does grab the latest version (1.0.0). 确实可以获取最新版本(1.0.0)。

Controller : 控制器

def show
  respond_to do |format|
    format.pdf { render pdf: 'show.pdf.prawn' }
    # ...
  end
end

HAML view : HAML视图

= link_to object_url(object, format: :pdf) do
  %button.btn.btn.default Print

show.pdf.prawn : show.pdf.prawn

prawn_document do
  pdf.text "Some text"
end

config/initializers/prawn-rails.rb : config / initializers / prawn-rails.rb

require 'prawn-rails'

PrawnRails.config do |config|
  config.page_layout = :portrait
  config.page_size = 'LETTER'
  config.skip_page_creation = true
end

This is all according to the README of the prawn-rails repository. 所有这些都根据prawn-rails存储库的自述文件进行。

But I get ActionView::Template::Error (undefined local variable or method 'pdf' for #<#<Class:0x005618ff5021e8>:0x005618ff97b968>) . 但是我得到了ActionView::Template::Error (undefined local variable or method 'pdf' for #<#<Class:0x005618ff5021e8>:0x005618ff97b968>)

Any thoughts? 有什么想法吗? Should I just report this as an issue on the repo? 我是否应该将此作为回购报告中的问题报告?

Should be: 应该:

prawn_document do |pdf|
  pdf.text "Some text"
end

I'd send them a note and tell them to update their README. 我会给他们发送便条,并告诉他们更新其自述文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM